Using Matlab Write code that does the following Create N random variables (X_1,
ID: 2082807 • Letter: U
Question
Using Matlab
Write code that does the following
Create N random variables (X_1, ...X_N) each with L samples. These should be independent and identically distributed. Generate S_n, which will be the sum of these random variables. Find the mean and variance of X_1 i.e. mu and sigma_2. Since the RV's are iid's, mu will be the mean of all the other RV's in this set too. You can verify this by finding the mean of a few other variables. Create the random variable Z_n by adding N random variables as: Z_n = s_n - n mu/sigma Squareroot n Plot the pdf of Z_n Repeat steps 3 and 4 for N = 10, N = 50 and N = 100. For each case, repeat for values of L = 100, 1000, 10,000 and 1000,000. Comment on the effects of the various values of L and N. Repeat for each of the three RV's listed below: Uniform random variable Exponential random variable (lambda = 0.5) Gaussian random variable (mu = 5, sigma = 2)Explanation / Answer
matlab code:
1)%(a)
N=10;
L=100;
X=rand(N,L)
Sn=sum(X)
2)
%(b)
mue=mean(X(1,:))
sigma_square=var(X(1,:))
3)
for n=1:1:L
Zn(n)=(Sn(n)-n.*mue)./(sqrt(sigma_square).*sqrt(n));
end
4)
figure;
n=1:100;
plot(n,Zn);
xlabel('it n ightarrow');
ylabel('it Zn ightarrow');
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.