www.gusucode.com > stats 源码程序 matlab案例代码 > stats/CDFOfHalfNormalProbabilityDistributionExample.m
%% CDF of Half-Normal Probability Distribution % This example shows how changing the values of the |mu| and |sigma| % parameters alters the shape of the cdf. %% % Create four probability distribution objects with different parameters. pd1 = makedist('HalfNormal'); pd2 = makedist('HalfNormal','mu',0,'sigma',2); pd3 = makedist('HalfNormal','mu',0,'sigma',3); pd4 = makedist('HalfNormal','mu',0,'sigma',5); %% % Compute the cumulative distribution functions (cdfs) for each probability % distribution. x = 0:0.1:10; cdf1 = cdf(pd1,x); cdf2 = cdf(pd2,x); cdf3 = cdf(pd3,x); cdf4 = cdf(pd4,x); %% % Plot all four cdfs on the same figure. figure; plot(x,cdf1,'r','LineWidth',2) hold on; plot(x,cdf2,'k:','LineWidth',2); plot(x,cdf3,'b-.','LineWidth',2); plot(x,cdf4,'g--','LineWidth',2); legend({'mu = 0, sigma = 1','mu = 0, sigma = 2',... 'mu = 0, sigma = 3','mu = 0, sigma = 5'},'Location','SE'); hold off; %% % As |sigma| increases, the curve of the cdf flattens.