Fitting a Skewed Gamma Probability Distribution Function to Data, or fitting any skewed pdf to data.
Mostrar comentarios más antiguos
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.
Respuestas (2)
Peter Perkins
el 15 de Mayo de 2012
Editada: John Kelly
el 23 de Dic. de 2020
3 votos
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
el 13 de Mayo de 2012
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 comentarios
Tom Lane
el 14 de Mayo de 2012
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
el 14 de Mayo de 2012
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
el 18 de Nov. de 2013
I dont think this answer the question.
Robert
el 18 de Sept. de 2015
what is the value of x?
Categorías
Más información sobre Gamma Distribution en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!