www.gusucode.com > stats 源码程序 matlab案例代码 > stats/ComparePDFsOfStableDistributionsExample.m
%% Compare PDFs of Stable Distributions %% % The following plot compares the probability density functions for % stable distributions with different |alpha| values. In each case, |beta = 0|, % |gam = 1|, and |delta = 0|. pd1 = makedist('Stable','alpha',2,'beta',0,'gam',1,'delta',0); pd2 = makedist('Stable','alpha',1,'beta',0,'gam',1,'delta',0); pd3 = makedist('Stable','alpha',0.5,'beta',0,'gam',1,'delta',0); %% % Calculate the pdf for each distribution. x = -5:.1:5; pdf1 = pdf(pd1,x); pdf2 = pdf(pd2,x); pdf3 = pdf(pd3,x); %% % Plot all three pdf functions on the same figure for visual comparison. figure plot(x,pdf1,'b-'); hold on plot(x,pdf2,'r-.'); plot(x,pdf3,'k--'); title('Compare Alpha Parameters in Stable Distribution PDF Plots') legend('\alpha = 2','\alpha = 1','\alpha = 0.5','Location','northwest') hold off %% % The plot illustrates the effect of the |alpha| parameter on the tails of % the distribution. %% % The next plot compares the probability density functions for % stable distributions with different |beta| values. In each case, % |alpha = 0.5|, |gam = 1|, and |delta = 0|. pd1 = makedist('Stable','alpha',0.5,'beta',0,'gam',1,'delta',0); pd2 = makedist('Stable','alpha',0.5,'beta',0.5,'gam',1,'delta',0); pd3 = makedist('Stable','alpha',0.5,'beta',1,'gam',1,'delta',0); %% % Calculate the pdf for each distribution. x = -5:.1:5; pdf1 = pdf(pd1,x); pdf2 = pdf(pd2,x); pdf3 = pdf(pd3,x); %% % Plot all three pdf functions on the same figure for visual comparison. figure plot(x,pdf1,'b-'); hold on plot(x,pdf2,'r-.'); plot(x,pdf3,'k--'); title('Compare Beta Parameters in Stable Distribution PDF Plots') legend('\beta = 0','\beta = 0.5','\beta = 1','Location','northwest') hold off