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

    %% Compare Lognormal and Burr pdfs  
% This example shows how to compare the lognormal pdf to the Burr pdf using
% income data generated from a lognormal distribution.   

%% 
% Generate the income data. 
rng default % for reproducibility
y = random('logn',log(25000),0.65,500,1);

%% 
% Fit a Burr distribution. 
pd = fitdist(y,'burr');  

%% 
% Plot both the Burr and lognormal pdfs of income data on the same axis. 
p = pdf('burr',sortrows(y),26007,2.6374,1.0966);
p2 = pdf('logn',sortrows(y),log(25000),0.65);
plot(sortrows(y),p,'g',sortrows(y),p2,'r','LineWidth',2)
title('Burr and Lognormal pdfs fitted to income data')
legend('burr','lognormal')