rndseed 123456 ' FIX THE SEED FOR THE RANDOM NUMBER GENERATOR SO YOU CAN REPLICATE THE EXPERIMENT !nrep=100 ' THIS IS THE NUMBER OF REPLICATIONS (N) !n=9 ' THIS IS THE FIXED SAMPLE SIZE (n) vector(!nrep) av ' ASSIGN A STORAGE VECTOR FOR THE RESULTS series y 'DECLARE A NAME FOR THE SERIES OF SAMPLE VALUES smpl 1 !n ' FIX THE SAMPLE SIZE TO n ' HERE IS THE START OF THE MONTE CARLO "LOOP" for !i=1 to !nrep y=@runif(0,1) ' TAKE A RANDOM SAMPLE OF SIZE n FROM A POPULATION THAT'S UNIFORM ON ZERO-ONE. SO, ITS MEAN IS MU=0.5 AND ITS STANDARD DEVIATION IS SIGMA=0.288675 av(!i)=@mean(y) ' CONSTRUCT THE SAMPLE AVERAGE next ' THIS IS THE END OF THE MONTE CARLO "LOOP" ' NOW GET THE RESULTS INTO A PRESENTABLE FORM ' CONVERT THE VECTOR OF N VALUES OF THE SAMPLE AVERAGE INTO A SERIES SO IT CAN BE PLOTTED smpl 1 !nrep mtos(av, xbar) ' LOOK AT THE RESULTS FOR THE N VALUES OF THE SAMPLE AVERAGE & DISPLAY THE SAMPLING DISTRIBUTION OF THIS STATISTIC show xbar hist xbar scalar sd_of_xbar= @sqrt(1/12/!n) ' THE MEAN OF THE N VALUES OF XBAR SHOULD EQUAL THE TRUE VALUE OF "MU", WHICH IS 0.5 ' THE STANDARD DEVIATION OF THE N VALUES OF XBAR SHOULD EQUAL SIGMA / SQRT(n), where "SIGMA" = SQRT(1/12). ' BECAUSE THE POPULATION IS NORMALLY DISTRIBUTED, THE SAMPLING DISTRIBUTION OF XBAR WILL NOT BE NORMAL. '[ NOTE THAT IF n=2, THEN THE SUM OF THE SAMPLE VALUES, AND XBAR, ACTUALLY HAS A TRIANGULR DISTRIBUTION - YOU CAN CHECK THIS BY SETTING !n=2 AND !nrep=10000] ' HOWEVER, AS n GETS BIGGER AND BIGGER, THIS SAMPLING DISTRIBUTION APPROACHES A NORMAL DISTRIBUTION, BECAUSE OF THE CENTRAL LIMIT THEOREM. 'THEN, THE SKEWNESS IS ESSENTIALLY ZERO, AND THE KURTOSIS IS ESSNTIALLY 3. USING THE J-B TEST WE CANNOT REJECT NORMALITY OF THIS SAMPLING DISTRIBUTION IF n IS VERY LARGE