
% this program is used to fit normal distribution to a histogram

load presdata % load pressure coef data

nb=50;
[N,x]=hist(-cp,nb); % obtain the histogram for the pressure data

%we have change the sign of the data since the pdf 
%for Gamma distribution require that x>0

phat=gamfit(-cp);

y=gampdf(x,phat(1),phat(2));

y1=y*((max(x)-min(x))/nb);

plot(x,N/27000) % N/27000 for pdf
hold on
plot(x,y1,'-r')
title('Compare the pdf of the data to Gamma distribution')
legend('PDF of the data','Gamma pdf')
hold off
