Fitting a Skewed Gamma Probability Distribution Function to Data, or fitting any skewed pdf to data.
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposte (2)
Peter Perkins
il 15 Mag 2012
Modificato: John Kelly
il 23 Dic 2020
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.
0 Commenti
Oleg Komarov
il 13 Mag 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 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!