[SciPy-dev] Problem with F distribution, or with me?

josef.pktd@gmai... josef.pktd@gmai...
Sun Aug 24 14:49:09 CDT 2008

>On Wed, Aug 13, 2008 at 11:44,  <josef.pktd@gmail.com> wrote:
>> I think, stats.loggamma.rvs is wrong or uses a definition that I cannot figure out.
>It isn't related to log(gamma.rvs()). It is the same distribution as the "standard" version of lgammaff in VGAM:
>  http://rss.acs.unt.edu/Rdoc/library/VGAM/html/lgammaff.html
>Robert Kern


I still think there is a problem with the loggamma distribution. I am
attaching a script that compares the random variables generated with
scipy.stats.loggamma.rvs  with the theoretical distribution from
scipy.stats.loggamma.pdf and the explicit formula, which is the same
in scipy.stats.loggamma.pdf  as in the
http://rss.acs.unt.edu/Rdoc/library/VGAM/html/lgammaff.html. The
script produces many graphs for the range of parameters that seem
reasonable to me.

>From the histograms you can see that the fit of the sample to the
correct pdf is very weak and seems to hold only for some parameter
values, e.g. c=1, c=2. For c=1.5 or 1.6 which is in the range of the
kstest in the scipy tests, the fit does not look very good.

On the other hand, the log of a gamma random variable has a good fit
to the theoretical distribution in scipy.stats.loggamma.pdf.

I have not found any good statistics reference for the loggamma
distribution and its relationship to the log of a gamma random
variable, but from my interpretation of the results, they seem to have
the same distribution. But while googling, I saw neither a positive
nor a negative statement for this.

In my previous use of the gamma distribution in R, I think, I used the
correct random number generator VGAM.rlgamma, which is linked to in
your reference.

Note: I'm still using matplotlib-0.90.1 and for compatibility I had to
downgrade numpy to 1.0.4, my scipy version is 0.6.0. But I did not see
any relevant changes to scipy.stats in a quick look at the changelogs
in subversion/trac.

Can you run the attached file, and it should give you a quick overview
of whether my suspicious results are real, or whether something has
changed in newer versions, (or if I am really misinterpreting what is
supposed to be going on here).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: stats_distributions_loggamma_sh.py
Type: text/x-python
Size: 1885 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20080824/64b21764/attachment.py 

More information about the Scipy-dev mailing list