Monte Carlo Sampling Experiment

Asked by Gabriel Martinez

Gabriel Martinez (view profile)

on 6 Oct 2019 at 21:00
Latest activity Commented on by Walter Roberson

Walter Roberson (view profile)

on 6 Oct 2019 at 21:04
Hey,
I'm hoping you guys coud help with some homework. I'm really new to Matlab and my professor gave this to us and Im really lost. I have the could but not sure how to answer the questions. Any thoughts?
This is my homework:
Write up a report of the Monte Carlo experiment you performed to demonstrate that the expected scatter of sample means about the population mean really is well represented by the formal standard error estimate. Imagine you are trying to persuade someone who is skeptical about this claim. Begin by defining the sample mean, sample standard deviation and the standard error for the mean. Briefly explain the Monte Carlo experiment and show your code. Show your results, numerical and graphical, and explain them.
Find some way to show me that the sample vector x generated using the Matlab commands
N = 1000;
x = rand(N,1);
really does have a normal distribution.
Explain what you did in words, show your code, show the results, and interpret them.
This is my code so far
% genMonteCarlodata.m
% Function to calculate standard deviation (std), mean, and standar error of a certain file by calling it.
n = 100; % number of samples
ntrials = 1000;
rootn = sqrt(n);
smean = zeros(ntrials, 1);
sstdev = zeros(ntrials, 1); % preallocation
sterr = zeros(ntrials, 1);
for i = 1:ntrials % i = 1 to 1000 sample trials
x = randn(n,1);
smean(i) = mean(x); %sample mean
sstdev(i) = std(x); %sample standard deviation
sterr(i) = sstdev(i); %rootn
end
figure;
histogram(smean);
xlabel(''); ylabel('');
title('');
figure;
plot(x, '.');

Walter Roberson

Walter Roberson (view profile)

on 6 Oct 2019 at 21:04