Question

In today's lecture, several of you were suspicious of my claim that the E (i.e., distribution...

In today's lecture, several of you were suspicious of my claim that the E (i.e., distribution mean) of the ith element of a sample of size n is equal to the population mean, i.e. E[x_i] = E[x]. To convince you, write code to - take 10^7 samples of size 50 from a normal distribution with mu = 2 and sigma = 3, - select the 3rd element in each of the 10^7 samples, and store them in an array called x3. - compute the mean of x3. Convinced?! Note: your code will take a while to run because we are taking 10^7 samples (i.e., a large number). But that's what it takes to compute the E of something. E is a distribution mean, and the only way to approximate it numerically is to take a very large sample.

Homework Answers

Answer #1

I hope Rstudio is fine for the exercise, since you didn't mention a specific language.

x3=c() #Initialize the vector which will contain the 3rd element of each sample.
for (i in 1:10000000) {
sample_vector=rnorm(50,2,3) #This gives us a random sample of 50 elements from a normal distribution with mean=2 and standard deviation=3
x3=c(x3,sample_vector[3]) #This simply appends the 3rd element of the sample generated to the x3 vector

}
mean(x3) #This calculates the mean.

Note: The output will be different each time you run the code. Sample output I got:

Remember that output will differ every time you run this code. You may use set.seed to fix a simulation

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT