[SciPy-dev] cdflib wrapper - missing functions?

Neal Becker ndbecker2 at gmail.com
Sun May 18 18:43:33 EDT 2008


Robert Kern wrote:

> On Sun, May 18, 2008 at 4:22 PM, Neal Becker <ndbecker2 at gmail.com> wrote:
>> I'm interested in cdf for non-central chi-square, to use for r.v.
>> generation.  I noticed that scipy has cdflib, and I see cdflib has
>> cumchf,
>> which seems to be what I want.  It looks like cdflib_wrappers.c does not
>> expose cumchf?
> 
> It's not exposed there because the Cephes library already provides it.
> See scipy.special.chndtr*. For random number generation, though, you
> should use numpy.random.noncentral_chisquare(). If you want all of
> that bundled up into a distribution object, use scipy.stats.ncx2.
> 
Thanks for the tips!

I wonder if there are any references on the method used in
numpy.random.noncentral_chisquare?

This is the code:
double rk_noncentral_chisquare(rk_state *state, double df, double nonc)
{
    double Chi2, N;

    Chi2 = rk_chisquare(state, df-1);
    N = rk_gauss(state) + sqrt(nonc);
    return Chi2 + N*N;
}





More information about the SciPy-Dev mailing list