Hello, I am interested in using the random number distributions provided here:
https://www.gnu.org/software/gsl/manual/html_node/Random-Number-Distributions.html Ideally, I would like to make an executable that will return a random value according to a specified distribution on each call. It seems like the recommended usage of these functions will produce deterministic output on each run if the seed is the same (e.g., see https://www.gnu.org/software/gsl/manual/html_node/Random-Number-Distribution-Examples.html#Random-Number-Distribution-Examples ). I could set the seed to a new value on each call (GSL_RNG_SEED=2 ./tmp) but I am wondering if there is a better way. >From the last example shown here https://www.gnu.org/software/gsl/manual/html_node/Random-Number-Distribution-Examples.html#Random-Number-Distribution-Examples : [ Desktop ] $ cat tmp.c #include <stdio.h> #include <gsl/gsl_cdf.h> int main (void) { double P, Q; double x = 2.0; P = gsl_cdf_ugaussian_P (x); printf ("prob(x < %f) = %f\n", x, P); Q = gsl_cdf_ugaussian_Q (x); printf ("prob(x > %f) = %f\n", x, Q); x = gsl_cdf_ugaussian_Pinv (P); printf ("Pinv(%f) = %f\n", P, x); x = gsl_cdf_ugaussian_Qinv (Q); printf ("Qinv(%f) = %f\n", Q, x); return 0; } [ Desktop ] $ gcc -Wall -I/usr/include -c tmp.c [ Desktop ] $ gcc -L/usr/lib tmp.o -lgsl -lgslcblas -lm -o tmp [ Desktop ] $ ./tmp prob(x < 2.000000) = 0.977250 prob(x > 2.000000) = 0.022750 Pinv(0.977250) = 2.000000 Qinv(0.022750) = 2.000000 [ Desktop ] $ ./tmp prob(x < 2.000000) = 0.977250 prob(x > 2.000000) = 0.022750 Pinv(0.977250) = 2.000000 Qinv(0.022750) = 2.000000 [ Desktop ] $ ./tmp prob(x < 2.000000) = 0.977250 prob(x > 2.000000) = 0.022750 Pinv(0.977250) = 2.000000 Qinv(0.022750) = 2.000000 Best, Eric
