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
2012년 5월 15일
편집: John Kelly
2020년 12월 23일
3 개 추천
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.
Oleg Komarov
2012년 5월 13일
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
Tom Lane
2012년 5월 14일
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.
Oleg Komarov
2012년 5월 14일
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.
Nathan Orloff
2013년 11월 18일
I dont think this answer the question.
Robert
2015년 9월 18일
what is the value of x?
카테고리
도움말 센터 및 File Exchange에서 Gamma Distribution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!