Hey everyone, I want to add a range for my random distribution but I did'nt succeed, need some help. I want to put a range max value and min value for the random distribution.
here is my distribution :
[ real d, va_unif1,va_unif2,va_gauss;
real pi;
real c;
real mu;
real sig;
real dmin;
real dmax;
/*real d=P_DIAM(p);*/
pi = 2.*acos(0.);
c = 1811;
sig = 0.37;
mu = -0.67;
This expression doesn't do what I suggested: va_unif1 = (max-min)*(real) rand() / ((real) RAND_MAX + min);
your code is now dividing by ((real) RAND_MAX + min)
take the original code: va_unif1 = (real) rand() / (real) RAND_MAX;
multiply the right-hand side by the factor (max-min): va_unif1 = (max-min)*((real) rand() / (real) RAND_MAX);
then add min va_unif1 = (max-min)*((real) rand() / (real) RAND_MAX) + min;