[SciPy-User] [SciPy-dev] Bug/Error with chi-squared distribution and df<1

josef.pktd at gmail.com josef.pktd at gmail.com
Tue Sep 22 15:02:56 EDT 2009


On Tue, Sep 22, 2009 at 2:48 PM, Pierre GM <pgmdevlist at gmail.com> wrote:
>
> On Sep 22, 2009, at 2:27 PM, josef.pktd at gmail.com wrote:
>>>>> I'm not an expert on distributions, but as far as I can tell, the
>>>>> chi2
>>>>> distribution is defined for degrees of freedom >0.
>
> Mmh, could anybody point me to a *real* case where we would have less
> than 1 degree of freedom ?
> Check the definition of the X2 on wikipedia, for example: if k
> variables are iid scaled normal, their sum is X2 w/ k degrees of
> freedom (dfs). Naturally, k, the dfs are integers, and that makes
> quite sense to prevent the use of 0 < k < 1. Or returning NaNs instead
> of raising an exception...
>

If you forget about the definition in the context of statistical
tests, then it is just another one-parameter distribution that might
fit some data. There are quite a few distributions that were developed
for a narrower statistical usage, but can easily be used just for
fitting, e.g. I was estimating the parameters of a t distribution, and
it is much easier to do when the integer constraint is ignored.


The same as for the cdf also applies to the isf/ppf of the chi2, see
below. I cannot verify it currently with the generic methods because
of the nans in the cdf.

Josef


>>> stats.chi2.ppf(0.5,2)
1.3862943611198906
>>> q=0.5;df=2;special.gammainccinv(df/2., q)*2
1.3862943611198906
>>> stats.chi2.ppf(0.5,2.5)
1.8738477677808791
>>> q=0.5;df=2.5;special.gammainccinv(df/2., q)*2
1.8738477677808791
>>> stats.chi2.ppf(0.5,0.5)
nan
>>> q=0.5;df=0.5;special.gammainccinv(df/2., q)*2
0.087347604705746817
>>> special.chdtri(df, q)
nan
>>>


>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list