Cumulative distribution function (cdf) - empirical vs theoretical ?

Hello to all,

I have a data-set with n = 90, probably follows the gamma distribution. I used the maximum-likelihood estimation (MLE) to estimated the alpha and beta parameters of the gamma distribution using Matlab.
My question is
What is the best way to test the fit (goodness of fit) of the gamma distribution with the estimated parameters versus the original data-set ?

Can I compare the Cumulative distribution function (cdf) - empirical vs theoretical ?

empirical_cdf = ecdf ( data set )
theoretical_cdf = cdf ( gammafit )

And make same test, for example the KS two samples

kstest2 ( empirical_cdf, theoretical_cdf )

Is this the correct way ?


Super Moderator
My response, based on what you described above, would be indeed that this one way of approaching of what you're trying to yeah...proceed. There are other ways to do it, but what you're doing seems to me "okay."
Hi Dragan,

Thank you for your response. I have another idea.
Compare (test) the original data-set with a random sample generated using the parameters estimated, for example:

random_number = gamrnd ( estimated alpha, estimated beta )

and make same test

kstest2 ( original data-set, random_number)

does it make more sense (or less) ?

Many thanks


Super Moderator
No, I think your first approach is better than the second one. I see problems with sampling fluctuation based on in generating a random sample with a N size of 90 from the population - if that's what your thinking of doing.