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

7 ビュー (過去 30 日間)
Josie
Josie 2012 年 5 月 13 日
編集済み: John Kelly 2020 年 12 月 23 日
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.

Oleg Komarov
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 件のコメント
Nathan Orloff
Nathan Orloff 2013 年 11 月 18 日
I dont think this answer the question.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by