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

MATLAB PROBLEM: When you take data from some complex engineering situation, you

ID: 3681112 • Letter: M

Question

MATLAB PROBLEM: When you take data from some complex engineering situation, you often do not know what distribution the data follows. Let’s mimic that situation here by studying the process that generates N random numbers x as x=rand(N,1).^0.2, i.e., a uniform random variable raised to the 1/5th power. SHOW CODE PLEASE TO HELP ME CORRECT MY WORK.

(a) Start by getting a feel for what the distribution looks like by drawing histograms for dierent values of N using dierent widths of the histogram bars. Can you guess what the probability density function f(x) is?

(b) Use N = 1000 to compute a 95% condence interval on the mean µ. Hint: use the Central Limit Theorem.

(c) For N = 1000 samples, can you estimate a 95% condence interval on the variance 2? This is not something we have done in class, so you need to think a bit here. Hint: Remember that the whole denition of a 95% condence interval is that it will contain the true value 95% of the time. So if you sample N = 1000 once and nd the sample variance s2, and then repeat this same calculation (i.e., in a loop) a total of m times (where m is rather large), then the condence interval is the interval that contains the middle 95% of those s2 values. Another hint: draw a histogram of the s2 values you found.

Explanation / Answer

close all; clear all; m= 10;
for i=1: m

N=1000;
x=rand(N,1).^0.2 ;
Pdf=zeros(size(x)); % Pdf is an array of zeros and of the same size as x
% use the built-in find function to find the Indices of x whose values are in the range [0,1]
Indices = find(x>=0 & x<=1);
Pdf(Indices) = 1; % Set these indices in array Pdf to 1=PDF of X over [0,1]
figure; plot (x,Pdf) ;
axis([-0.2 1.2 -0.2 1.2]) ;
figure('position',[ 10*i, 10*i, 200,200]) ;
hist(x) ;
% histogram(x) ;xbins1 = -4:4; hist(x,xbins1) ;
% CI = mean(x)+- t * (s / square(n))
s2(i) =std(x)
SEM = std(x)/sqrt(length(x)) ; % Standard Error
ts = tinv([0.025 0.975],length(x)-1) ; % T-Score
CI = mean(x) + ts*SEM
end;
figure; hist(s2) ;