Hi all,
I am a newbie with a problem,I want to have a random number generator
which generate numbers satisfied normal distribution(gaussian).I found
that GNU GSL lib provids some functions which could do this ,but i still
can not control the mean value and upper/lower limit it generated.below
is the code :
===================================
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
int main (void)
{
const gsl_rng_type * T;
gsl_rng * r;
// select random number generator
r = gsl_rng_alloc (gsl_rng_mt19937);
double sigma = 10;
for (int i = 0; i < 10; i++)
{
double v = gsl_ran_gaussian_tail(r,4.5, sigma);
}
gsl_rng_free (r);
return 0;
}
===============================
one problem is ,it does not cut off from 4.5 and generated very big
numbers,i want to control the output ,say,between 0-100 with mean 50,is
there any way could do that ?
Thanks a lot,guys!!