...
 
Commits (4)
......@@ -53,7 +53,7 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
RANDOMSERIES_VERSION "\n"
"usage: randomseries filename [-v] [-t type] [-o]" "\n"
"usage: randomseries filename [-v] [-rngtype t] [-t type] [-o]" "\n"
" [-nseries n] [-nsamples n] [-dt v]" "\n"
" [-std v] [-mean v] [-seed n]" "\n"
" [-rngtype rng]" "\n"
......@@ -76,6 +76,10 @@ int main(int iargc, char* argv[])
"filename name of output file\n"
"-v be verbose\n"
"-o overwrite existing output file\n"
"-rngtype t select random number generator type\n"
" run\n"
" randomseries -xhelp=gslrng\n"
" to see comments\n"
"-t type select output file type\n"
"-nseries n produce 'n' time series\n"
"-nsamples n produce 'n' samples per series\n"
......
......@@ -54,6 +54,7 @@
# 06/02/2019 V1.0 Thomas Forbriger
# 18/09/2019 V1.1 provide fixed seed value on request to reproduce
# publication example exactly
# 04/11/2019 V1.2 prefer randomseries to create time series
#
# ============================================================================
#
......@@ -105,91 +106,40 @@ cleanseed: ;
# set time series parameters
# --------------------------
CPSD_DT=0.01
CPSD_DUR=8640.065
#CPSD_DUR=8640.065
#CPSD_DUR=864.
CPSD_N=864007
# ----------------------------------------------------------------------
# create raw time series
# ----------------------
# Several time series of normally distributed random samples with zero mean
# are computed with siggenx. To make them incoherent, each run requires its
# own specific seed value for the random number generator. We use the
# nanosecond field of the system clock.
# are computed with randomseries.
#
CPSD_SIGGENOPT=-v -o -d $(CPSD_DT) -T $(CPSD_DUR) -ot bin
# set random number generator type
# --------------------------------
#
# Quotation from
# https://www.gnu.org/software/gsl/doc/html/index.html
# https://www.gnu.org/software/gsl/doc/html/rng.html#random-number-generator-algorithms
#
# The following generators are recommended for use in simulation. They have
# extremely long periods, low correlation and pass most statistical tests.
# For the most reliable source of uncorrelated numbers, the second-generation
# RANLUX generators have the strongest proof of randomness.
#
# gsl_rng_ranlxd1
# gsl_rng_ranlxd2
#
# These generators produce double precision output (48 bits) from the
# RANLXS generator. The library provides two luxury levels ranlxd1 and
# ranlxd2, in increasing order of strength.
#
# gsl_rng_ranlux
# gsl_rng_ranlux389
#
# The ranlux generator is an implementation of the original algorithm
# developed by Luscher. It uses a lagged-fibonacci-with-skipping
# algorithm to produce “luxury random numbers”. It is a 24-bit
# generator, originally designed for single-precision IEEE floating
# point numbers. This implementation is based on integer arithmetic,
# while the second-generation versions RANLXS and RANLXD described
# above provide floating-point implementations which will be faster
# on many platforms. The period of the generator is about 10^{171}.
# The algorithm has mathematically proven properties and it can
# provide truly decorrelated numbers at a known level of randomness.
# The default level of decorrelation recommended by Luscher is
# provided by gsl_rng_ranlux, while gsl_rng_ranlux389 gives the
# highest level of randomness, with all 24 bits decorrelated. Both
# types of generator use 24 words of state per generator.
#
# For more information see,
#
# * M. Luscher, “A portable high-quality random number generator for
# lattice field theory calculations”, Computer Physics Communications,
# 79 (1994) 100–110.
# * F. James, “RANLUX: A Fortran implementation of the high-quality
# pseudo-random number generator of Luscher”, Computer Physics
# Communications, 79 (1994) 111–114
# run
# randomseries -xhelp=gslrng
# to see comments
#
RNGTYPE=ranlux
# Choose:
RNGTYPE=ranlxd2
# allow to reproduce publication example exactly
ifdef FIXEDSEED
cpsd1raw.seed: ;printf "%s\n" 686293391 > $@
cpsd2raw.seed: ;printf "%s\n" 448546898 > $@
cpsd3raw.seed: ;printf "%s\n" 021371780 > $@
cpsd4raw.seed: ;printf "%s\n" 559720675 > $@
cpsdbgraw.seed: ;printf "%s\n" 137374844 > $@
else
cpsd1raw.seed: ;printf "%s\n" $$(date +"%N") > $@
cpsd2raw.seed: ;printf "%s\n" $$(date +"%N") > $@
cpsd3raw.seed: ;printf "%s\n" $$(date +"%N") > $@
cpsd4raw.seed: ;printf "%s\n" $$(date +"%N") > $@
cpsdbgraw.seed: ;printf "%s\n" $$(date +"%N") > $@
endif
cpsd1raw.bin cpsd2raw.bin cpsd3raw.bin cpsd4raw.bin cpsdbgraw.bin: \
%.bin: %.seed
/bin/bash -c 'export GSL_RNG_SEED=$$(cat $<); \
export GSL_RNG_TYPE=$(RNGTYPE); \
siggenx 14 $@ $(CPSD_SIGGENOPT); \
echo seed: $$GSL_RNG_SEED > $(patsubst %.bin,%seed.xxx,$@)'
# time series for common noise signal: cpsdbgraw.bin
RNGSEED=0
cpsdrawseries.bin:
randomseries -v -o -t bin -rngtype $(RNGTYPE) -nseries 5 \
-nsamples $(CPSD_N) -dt $(CPSD_DT) -seed $(RNGSEED) \
-std 1. -mean 0. $@
cpsd1raw.bin cpsd2raw.bin cpsd3raw.bin cpsd4raw.bin: \
%.bin: cpsdrawseries.bin
any2any --verb --over --itype bin --otype bin \
$@ $< t:$(patsubst cpsd%raw.bin,%,$@)
cpsdbgraw.bin: \
%.bin: cpsdrawseries.bin
any2any --verb --over --itype bin --otype bin \
$@ $< t:5
# provide a time series plot to confirm incoherence
rawsig.ps: cpsd1raw.bin cpsd2raw.bin cpsd3raw.bin cpsd4raw.bin cpsdbgraw.bin
......@@ -514,31 +464,34 @@ crosscompilation.pdf: $(addprefix cross,$(addsuffix psd.pdf,$(CPSD_SET)))
#
white1.seed: ;printf "%s\n" 686293391 > $@
white2.seed: ;printf "%s\n" 448546898 > $@
WHITEN=100
WHITE_N=10000
whiterawseries.bin:
randomseries -v -o -t bin -rngtype $(RNGTYPE) -nseries 2 \
-nsamples $(WHITE_N) -dt $(CPSD_DT) -seed $(RNGSEED) \
-std 1. -mean 0. $@
white1.bin white2.bin: \
%.bin: %.seed
/bin/bash -c 'export GSL_RNG_SEED=$$(cat $<); \
export GSL_RNG_TYPE=$(RNGTYPE); \
siggenx 14 RAW$@ -a 7.07 -v -o -d $(CPSD_DT) -T $(WHITEN) -ot bin; \
echo seed: $$GSL_RNG_SEED > $(patsubst %.bin,%seed.xxx,$@)'
%.bin: whiterawseries.bin
any2any --verb --over --itype bin --otype bin \
RAW$@ $< t:$(patsubst white%.bin,%,$@)
sehefixx RAW$@ $@ \
-verbose -overwrite -itype bin -otype bin -ss WHI \
-sc $(patsubst white%.bin,%,$@) -si $(WHITEN)
-sc $(patsubst white%.bin,%,$@) -si $(WHITE_N)
white%_100.bin:
/bin/rm -fv $(patsubst white%_100.bin,white%.bin,$@)
$(MAKE) $(patsubst white%_100.bin,white%.bin,$@) WHITEN=100
$(MAKE) $(patsubst white%_100.bin,white%.bin,$@) WHITE_N=100
/bin/mv -fv $(patsubst white%_100.bin,white%.bin,$@) $@
white%_1000.bin:
/bin/rm -fv $(patsubst white%_1000.bin,white%.bin,$@)
$(MAKE) $(patsubst white%_1000.bin,white%.bin,$@) WHITEN=1000
$(MAKE) $(patsubst white%_1000.bin,white%.bin,$@) WHITE_N=1000
/bin/mv -fv $(patsubst white%_1000.bin,white%.bin,$@) $@
white%_10000.bin:
/bin/rm -fv $(patsubst white%_10000.bin,white%.bin,$@)
$(MAKE) $(patsubst white%_10000.bin,white%.bin,$@) WHITEN=10000
$(MAKE) $(patsubst white%_10000.bin,white%.bin,$@) WHITE_N=10000
/bin/mv -fv $(patsubst white%_10000.bin,white%.bin,$@) $@
WHITE_LOG=--log 20
......