39 #define SIM_DURATION 40000000L
65 char seednames[]={
'x',
'y',
'z',
't'};
66 read_con=generatorZ->
read(generatorZ);
67 for(count=0;count<4;count++)
68 printf(
"seed %c = %ldL\n", seednames[count], read_con[count]);
74 double mean=0, moment2=0, unif, variance, prob;
81 moment2 += (unif*unif);
84 moment2 /= (SIM_DURATION-1.0);
85 variance = moment2-mean*mean*(
SIM_DURATION)/(SIM_DURATION-1.0);
86 printf(
"Mean after %ld iterations is %lf; sample variance is %lf\n", SIM_DURATION, mean, variance);
87 printf(
"Seeds to use for next run:\n");
94 sequence->
init(sequence, 1L,2L,3L,4L);
98 moment2 += (unif*unif);
101 moment2 /= (SIM_DURATION-1.0);
102 variance = moment2-mean*mean*(
SIM_DURATION)/(SIM_DURATION-1.0);
103 printf(
"Mean after %ld iterations is %lf; sample variance is %lf\n", SIM_DURATION, mean, variance);
104 printf(
"Seeds to use for next run:\n");
110 for(count = 1;count<=50000;count++)
112 printf(
"\nMean number of tries until first success, each trial with probability %lf: %lf\n"
113 ,prob,mean/(count-1));
116 for(count = 1;count<=50000;count++)
118 printf(
"\n%ld fair coin tosses: Mean: %lf (should approach zero)\n",count-1,mean/(count-1));
119 prob = 0.666666666666666666;
121 for(count = 1;count<=50000;count++)
123 printf(
"\nMean number of successes in 30 trials with prob. of success %lf is %lf", prob, mean/(count-1));
127 for(count = 1;count<=50000;count++)
129 printf(
"\nMean result of %ld dice throws: %lf", count-1, mean/(count-1));