I am using normal(mean, sigma) to generate random number for normal distribution with mean and sigma. My sigma is 8db and mean is 0. But I always get negative value when I do normal(mean, sigma). Is there any way I can get positive number for this?
I am using normal(mean, sigma) to generate random number for normal distribution with mean
Share
You do not simply call
normal(double mean, double sigma).Instead, call
double r8_normal ( double a, double b, int &seed ), whereais the mean,bis the sigma, andseedinitializes the random number generator.I was able to compile and use the Normal library in the link you provided.
I downloaded normal.cpp and normal.hpp. These are old files, mostly translations from Fortran.
I had to modify normal.hpp by adding
#include <complex>and changingcomplextostd::complexin the first two declarations to get it to compile for me at low warning levels.Then I created a test driver:
which gives this output
And everything looks like it’s working for me for mean = 0.0, sigma = 8.0.