Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need MATLAB code, thank you Draw a sample of n points from the standard normal d

ID: 3787360 • Letter: N

Question

Need MATLAB code, thank you

Draw a sample of n points from the standard normal distribution. b. Compute the mean and standard deviation of this sample. c. Form the statistic t = (x - mu)/(s/Squareroot n) where x and s are the mean and the standard deviation computed in (b), mu = 0 (standard normal distribution) and n = 20. Store this value d. Repeat steps (a)- (c) about 5000 times. e. Plot the histograms of the statistic and verify visually that it looks like a t-distribution Determine the two-sided probabilities associated with 60%, 70%, 80%, 90%, 95% and 99% (We have been working exclusively with two-sided probabilities in this class) f. Repeat the process a-e for various values of n (degrees of freedom) (Some relevant MATLAB functions: randn mean std, hist prctile)

Explanation / Answer

(a) %Initialize n to any number.

r=randn(n)

(b) %To find mean and standard deviation

mean_r=mean(r);

std_r=std(r);

(c) %To compute statistic t

r=randn(20)

mean_r=mean(r)

std_r=std(r)

t=mean_r/(std_r*sqrt(20))

(d) for i=1:5000

r=randn(20)

mean_r=mean(r)

std_r=std(r)

t=mean_r/(std_r*sqrt(20))

end

(e) n=20;

t=[]

for i=1:5000

r=randn(n);

mean_r=mean(r);

std_r=std(r);

t(i)=mean_r/(std_r*sqrt(20));

end

%Plot histogram

hist(t)

(f) You can change thae values of n.

function []=plothistrandomvalues(n)

  r=randn(n)

for i=1:5000

mean_r=mean(r)

std_r=std(r)

t=mean_r/(std_r*sqrt(20))

end

hist(t)

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote