www.gusucode.com > stats 源码程序 matlab案例代码 > stats/ComparisonPlotForStableDistributionsExample.m
%% Comparison Plot for Stable Distributions % The following plot compares the probability density functions for the % standard normal, Cauchy, and Lévy distributions. %% % Create a probability distribution object for the standard normal, % Cauchy, and Lévy distributions. pd_norm = makedist('Stable','alpha',2,'beta',0,'gam',1/sqrt(2),'delta',0); pd_cauchy = makedist('Stable','alpha',1,'beta',0,'gam',1,'delta',0); pd_levy = makedist('Stable','alpha',0.5,'beta',1,'gam',1,'delta',0); %% % Calculate the pdf for each distribution. x = -5:.1:5; pdf_norm = pdf(pd_norm,x); pdf_cauchy = pdf(pd_cauchy,x); pdf_levy = pdf(pd_levy,x); %% % Plot all three pdf functions on the same figure for visual comparison. figure plot(x,pdf_norm,'b-'); hold on plot(x,pdf_cauchy,'r.'); plot(x,pdf_levy,'k--'); title('Compare Stable Distributions pdf Plots') legend('Normal','Cauchy','Levy','Location','northwest') hold off