Simulation of Cauchy random variables and calculating empirical CDF followed by plotting them
4 ビュー (過去 30 日間)
古いコメントを表示
Question: Simulated some Cauchy random variables (200) and calculate the empirical distribution function F_n and also make a vector F for the theoretical cdf. Plot F and Fn on the same figure.
Below is what I did and the output I got.
% Matlab HW for Advanced statistics
ULst = rand(200,1);
CauchyLst = tan(pi*(ULst-0.5));
SortCauchyLst = sort(CauchyLst);
plot(SortCauchyLst,'*') %middle step to get a quick picture
tLst = -20:0.01:15;
FnLst = [];
for t=-20:0.01:15
Fn = 1/100*sum(CauchyLst<=t);
FnLst = [FnLst,Fn];
end
FLst = [];
for t=-20:0.01:15
F = (1/pi)*atan(t)+0.5;
FLst = [FLst,F];
end
plot(tLst,FLst)
hold on
plot(tLst,FnLst,'r.')
hold on
[f,x] = ecdf(Fn);
ecdf(Fn)
hold on
[h,stats] = cdfplot(F);
cdfplot(F)
hold off
% End of script
Can someone please verify if this is correct or wrong? Kindly help me out if this is incorrect. Thanks in advance.
0 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!