www.gusucode.com > stats 源码程序 matlab案例代码 > stats/CompareCDFsOfStableDistributionsExample.m

    %% Compare CDFs of Stable Distributions

%%
% The following plot compares the cumulative distribution 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 cdf for each distribution.
x = -5:.1:5;
cdf1 = cdf(pd1,x);
cdf2 = cdf(pd2,x);
cdf3 = cdf(pd3,x);

%%
% Plot all three cdf functions on the same figure for visual comparison.
figure
plot(x,cdf1,'b-');
hold on
plot(x,cdf2,'r-.');
plot(x,cdf3,'k--');
title('Compare Alpha Parameters in Stable Distribution CDF Plots')
legend('\alpha = 2','\alpha = 1','\alpha = 0.5','Location','northwest')
hold off

%%
% The plot illustrates the effect of the |alpha| parameter on the shape of
% the cdf.

%%
% The next plot compares the cumulative distribution functions for 
% stable distributions with different |beta| values. In all cases,
% |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 cdf for each distribution.
x = -5:.1:5;
cdf1 = cdf(pd1,x);
cdf2 = cdf(pd2,x);
cdf3 = cdf(pd3,x);

%%
% Plot all three pdf functions on the same figure for visual comparison.
figure
plot(x,cdf1,'b-');
hold on
plot(x,cdf2,'r-.');
plot(x,cdf3,'k--');
title('Compare Beta Parameters in Stable Distribution CDF Plots')
legend('\beta = 0','\beta = 0.5','\beta = 1','Location','northwest')
hold off