Hi,
2009/10/13 Sumesh P.T. <[email protected]>:
> Both sum and mean are positive values with no fluctuations around
> zero! Is not that surprising?
No, it's not. These 10 last sums and mean values you've shown are
correlated to each other: If you've accumulated a mean of 130 at some
point and add a few small random numbers to it, it will of course
remain somewhere near 130. It would only be surprising if you always
got a positive mean even if you use different initial values for the
RNG, but that's not the case (see example code below).
Cheers,
Frank
#include <time.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
int main() {
double y,sum=0.;
const gsl_rng_type * R;
gsl_rng * r;
gsl_rng_env_setup();
R = gsl_rng_default;
r = gsl_rng_alloc (R);
gsl_rng_set (r, time (0));
int i;
for(i=1;i<=10000;i++) {
y = gsl_ran_gaussian(r,1.);
sum=sum+y;
printf("%f, %f, %f ,\n",y,sum,sum/i);
}
}
_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl