PDF and CDF using central limit theorem

조회 수: 1 (최근 30일)
Eslearner
Eslearner 2019년 12월 11일
댓글: Dheeraj Singh 2019년 12월 20일
I am struggling to plot the PDF and CDF graphs of where using central limt theorem where n = 1; 2; 3; 4; 5; 10; 20; 40
I am taking Xi to be a uniform continuous random variable for values between (0,3).
Here is what i have done so far -
clc
clear all
close all
%different sizes of input X
N = [1 2 3 4 5 10 20 40];
%interval (1,6) for random variables
a=0;
b=3;
%to store sum of differnet sizes of input
for i=1:length(N)
%generates uniform random numbers in the interval
X = a + (b-a).*rand(N(i),1);
S=zeros(1,length(X));
S=cumsum(X);
cd=cdf('Uniform',S,0,3);
plot(cd);
hold on;
end
legend('n=1','n=2','n=3','n=4','n=5','n=10','n=20','n=40');
title('CDF PLOT')
figure;
for i=1:length(N)
%generates uniform random numbers in the interval
X = a + (b-a).*rand(N(i),1);
S=zeros(1,length(X));
S=cumsum(X);
cd=pdf('Uniform',S,0,3);
plot(cd);
hold on;
end
legend('n=1','n=2','n=3','n=4','n=5','n=10','n=20','n=40');
My output is nowhere near what I am expecting any help is much appreciated. ( I am really new to Matlab)
  댓글 수: 1
Dheeraj Singh
Dheeraj Singh 2019년 12월 20일
Can you elaborate more about what was your expected output and what output did you get?

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by