Question: scipy.stats.gamma.fit
Dear scipy-users, I'm using scipy.stats.gamma.fit to fit a set of random variables for gamma distribution. And to validate the results I also use the fitdistr function in R. However the results generated by these two packages are different, i.e. shape parameter and scale parameter for the gamma pdf are different. Though the difference is not large, I'm wondering what causes this difference. I think both of them are using maximum likelihood estimation to fit the function. Best regards! Ning
On Fri, Jul 1, 2011 at 3:48 AM, Ning Guo <hhh.guo@gmail.com> wrote:
Dear scipy-users,
I'm using scipy.stats.gamma.fit to fit a set of random variables for gamma distribution. And to validate the results I also use the fitdistr function in R. However the results generated by these two packages are different, i.e. shape parameter and scale parameter for the gamma pdf are different. Though the difference is not large, I'm wondering what causes this difference. I think both of them are using maximum likelihood estimation to fit the function.
Do you have an example or a test case? It's difficult to guess what might be different. None of the fit methods are verified against R or tested for correctness. Contributions to the test suite and possible bugfixes would be appreciated. Josef
Best regards! Ning _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
On Saturday, July 02, 2011 02:34 AM, josef.pktd@gmail.com wrote:
On Fri, Jul 1, 2011 at 3:48 AM, Ning Guo<hhh.guo@gmail.com> wrote:
Dear scipy-users,
I'm using scipy.stats.gamma.fit to fit a set of random variables for gamma distribution. And to validate the results I also use the fitdistr function in R. However the results generated by these two packages are different, i.e. shape parameter and scale parameter for the gamma pdf are different. Though the difference is not large, I'm wondering what causes this difference. I think both of them are using maximum likelihood estimation to fit the function. Do you have an example or a test case? It's difficult to guess what might be different. None of the fit methods are verified against R or tested for correctness.
Contributions to the test suite and possible bugfixes would be appreciated.
Josef
Best regards! Ning _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user Thanks Josef,
I simply used scipy.gamma.rvs(0.8,loc=0,scale=1.2,size=1000) to generate random variables, and then used scipy.gamma.fit() to estimate the parameters. To validate, I used fitdistr function in R and gamfit function in GNU Octave. These three packages give different results (fitdistr and gamfit offer closer results). Actually, I am not a statistics guy. I supposed they should generate exactly same results since they all use MLE. But now I see not necessarily exactly the same due to that mathematical implementation of MLE is very complicated. Since results are close to each other more or less, I'll not be bothered by the differences and will choose anyone for the fitting. Best regards! Ning -- Geotechnical Group Department of Civil and Environmental Engineering Hong Kong University of Science and Technology Clear Water Bay, Kowloon, Hong Kong
participants (2)
-
josef.pktd@gmail.com
-
Ning Guo