Fitting a Skewed Gamma Probability Distribution Function to Data, or fitting any skewed pdf to data.

Hello. I'm attempting to fit a positively (right) skewed gamma distribution to a set of data. I believe the correct matlab function to use is gamfit but am having trouble understanding the information found here: http://www.mathworks.com/help/toolbox/stats/gamfit.html
My data is as follows
data = [0, 0.048, 0.061, 0.089, 0.097, 0.088, 0.075, 0.065, 0.059, 0.049, 0.043];
time = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5];
Time is to be on the x axis. While I know how to plot just the data - plot(time,data) - I do not understand how to use the gamfit. Can someone help explain it to me, or show me how to use it please. If this is not possible, or you know how to do this with another skewed distribution that will work as well. Any skewed distribution is fine, I was just happened to be interested in the gamma one. Any help would be greatly accepted and appreciated. Many Thanks.

답변 (2개)

Peter Perkins
Peter Perkins 2012년 5월 15일
편집: John Kelly 2020년 12월 23일
Josie, since you have two variables, it sounds to me like you are not fitting a gamma PDF, but rather that you are fitting a curve that happens to have the same shape as a gamma pdf.
params = gamfit(rand)
returns the shape and the scale parameters of a Gamma distribution: http://en.wikipedia.org/wiki/Gamma_distribution
A full example:
data = [0, 0.048, 0.061, 0.089, 0.097, 0.088, 0.075, 0.065, 0.059, 0.049, 0.043];
% Fit gamma pdf to data
ab = gamfit(data);
% Write the functional form of the pdf with the estimated parameters
a = ab(1);
b = ab(2);
gpdf = @(x) x.^(a-1)/(b^a*gamma(a)).*exp(-x/b);
% Plot the fitted pdf and the data
x = 0:0.001:.3;
plot(x,gpdf(x),'-b',data,gpdf(data),'*r')
legend('Theoretical pdf','Data')
A note of warning:
The number of datapoints is very small to really say that this particular pdf is the right one. Also, I usually graph a normalized histogram against the theoretical pdf but here it wouldn't make much sense.
QUESTION
Even using gampdf(a,b,x) I get a non legit pdf, is this expected behaviour? My mistake (see comments below).

댓글 수: 4

gampdf(x,a,b) is willing to evaluate the pdf at a vector of b values, so that's what happens if you put the vector in the third position.
Thanks Tom for noting the typo, but I was mislead by the height of the pdf vs the probability. My bad, was too used to normal pdf that I forgot the basics.
I dont think this answer the question.

댓글을 달려면 로그인하십시오.

질문:

2012년 5월 13일

편집:

2020년 12월 23일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by