From successive sums of 12 uniform random variables (i.e., use the BASIC system RND() function) use the Central Limit Theorem and BASIC to generate a long sequence (>1000) of Normal random variables with zero mean and unity variance. Calculate the mean and variance for N=10,000 observations.
just want to understand the general idea of what the teach is asking
so basically create 1000 normal random variables using z = RND() + RND() + RND() + RND() + RND() + RND() + RND() + RND() + RND() + RND() + RND() + RND() -6
add them all up and find the average
from this, calculate the variance? why is it that you have 1000 pieces of sample data and 10,000 observations???
im in this class too i did something like this 08 N=10000 09 for J = 1 to N 10 for I = 1 to 12 11 x = 0 20 X = X + rnd(1) 30 next I 40 SUM = SUM + X - 6 41 AVG = SUM / N 50 print sum 60 print N 70 print AVG
hey sorry was looking at a another page
thats not right though
wait so you just do this for 10,000 numbers?
why does he have >1000
greater than 1000 is 10000
its unclear
yeah, not sure why he wrote it that way
are you in the 1pm class?
yes
ahh nice, i usually sit towards the back
grr this assignment is killing me. usually have everything done way ahead of schedule but had a bunch of other stuff due, so i'm struggling with finishing this last minute
how did you set up problem 2?
im in the same boat. although i'm a lifelong procrastinator.
lol
on your program i think you have it set up right except for lines 11 - 30
you should do RND() + RND() + RND() + RND() + RND() + RND() + RND() + RND() + RND() + RND() + RND() + RND() - 6
set that = to X
im testing it now, definite logic error
ah wait nm, you had it right. but yeh just add 10000 of them up then divide
import java.util.*; import java.lang.Math; public class NormalRNDVars { public static void main(String[] args) { Random rand = new Random(); double rnd = rand.nextDouble(); double z[] = new double[1002]; double average = 0, sum = 0, sample = 0; //Calculate normal random variable for(int i=1; i<=1000; i++) { z[i] = rnd + rnd + rnd + rnd + rnd + rnd + rnd + rnd + rnd + rnd + rnd + rnd - 6; } //Add all of the normal random variables for(int i=1; i<=1000; i++) { sum += z[i]; } //Calculate and print the average average = sum / 10000; System.out.printf("Average: %f\n", average); for(int i=1; i<=1000; i++) { sample += Math.pow(z[i] - average, 2); } sample = sample / (1000 - 1); System.out.printf("Variance: %f\n", sample); } }
if that helps
gotta catch a bus, cya in class
bye
Join our real-time social learning platform and learn together with your friends!