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

Use the following Matlab script to demonstrate the central limit theorem. (a) Co

ID: 3809945 • Letter: U

Question

Use the following Matlab script to demonstrate the central limit theorem. (a) Compute 20000 samples of Z = sigma^N_n = 1 X_n where X_n is a random variable uniformly distributed over [-1, 1] (b) Estimate the corresponding probability density function by forming a histogram of the results. (c) Compare this histogram to the Gaussian probability density function having same mean and variance. (d) What is the relative error between the two density functions at 0 sigma, 1 sigma, 2 sigma, 3 sigma and 4 sigma? (e) Compare the relative error results by increasing N as 5, 10, 15 and 20.

Explanation / Answer

Hi, you may use this below code to find answers for your questions. I've explained the Central Limit Theorem (CLT) in the easiest code/way possible -- ------------------------------------------------------------------------------------ clc;clear; len = 50000; lambda = 3; %yA : Exponential Distribution A yA=-log(rand(1,len))./lambda; %yB : Exponential Distribution B yB=-log(rand(1,len))./lambda; %yC : Exponential Distribution C yC=-log(rand(1,len))./lambda; %yD : Exponential Distribution D yD=-log(rand(1,len))./lambda; %yE : Exponential Distribution E yE=-log(rand(1,len))./lambda; %yF : Exponential Distribution F yF=-log(rand(1,len))./lambda; %yG : Exponential Distribution G yG=-log(rand(1,len))./lambda; %yH : Exponential Distribution H yH=-log(rand(1,len))./lambda; %yI : Exponential Distribution I yI=-log(rand(1,len))./lambda; %yJ : Exponential Distribution J yJ=-log(rand(1,len))./lambda; %y1 : What result you expect it to be (centred Gaussian with same variation as exponential): mean0 = 0; var0 = var(yA); y1 = mean0 + sqrt(var0)*randn(1,len); delta = 0.01; x1 = min(y1):delta:max(y1); figure('Name','Normal Distribution (Expected)'); hist(y1,x1); %Central Limit Theorem: %what result is: res1 = (((yA)/1) - mean(yA))*sqrt(1); res2 = (((yA+yB)/2) - mean(yA))*sqrt(2); res3 = (((yA+yB+yC)/3) - mean(yA))*sqrt(3); res4 = (((yA+yB+yC+yD)/4) - mean(yA))*sqrt(4); res5 = (((yA+yB+yC+yD+yE)/5) - mean(yA))*sqrt(5); res10 = (((yA+yB+yC+yD+yE+yF+yG+yH+yI+yJ)/10) - mean(yA))*sqrt(10); delta = 0.01; xn = min(res1):delta:max(res1); figure('Name','Final Result for N=1'); hi st(res1,xn); xn = min(res2):delta:max(res2); figure('Name','Final Result for N=2'); hist(res2,xn); xn = min(res3):delta:max(res3); figure('Name','Final Result for N=3'); hist(res3,xn); xn = min(res4):delta:max(res4); figure('Name','Final Result for N=4'); hist(res4,xn); xn = min(res5):delta:max(res5); figure('Name','Final Result for N=5'); hist(res5,xn); xn = min(res10):delta:max(res10); figure('Name','Final Result for N=10'); hist(res10,xn); %for N = 100 y100=-log(rand(100,len))./lambda; res100 = ((sum(y100)/100) - mean(yA))*sqrt(100); xn = min(res100):delta:max(res100); figure('Name','Final Result for N=100'); hist(res100,xn);

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