[SciPy-Dev] Wallenius hypergeometric distribution

Evgeni Burovski evgeny.burovskiy at gmail.com
Mon Aug 10 08:01:42 EDT 2020


Does it need to carry its own Mersenne Twister implementation? Mixing
different random streams is prone to surprises, can the scipy version rely
on numpy.random instead?

вс, 9 авг. 2020 г., 23:26 Matt Haberland <mhaberla at calpoly.edu>:

> Hi Team,
>
> Here's the noncentral hypergeometric distribution code we have permission
> to distribute under the BSD license:
> https://www.agner.org/random/stocc.zip
> Ralf suggested I send it around to see if there are any opinions about
> using it.
>
> It doesn't include two files that are needed to build it (mersenne.cpp and
> userintf.cpp), but we want to replace those anyway. In the meantime, you
> can find those files here <https://www.agner.org/random/randomc.zip>.
>
> Alternatively, you can check out my branch:
> https://github.com/mdhaber/scipy/tree/nchg
> in which I've started a wrapper for Fisher's noncental hypergeometric
> distribution.
> Everything we'd be using is in scipy/stats/biasedurn
> <https://github.com/mdhaber/scipy/tree/nchg/scipy/stats/biasedurn>. The
> Cython files are BiasedUrn.pxd
> <https://github.com/mdhaber/scipy/blob/nchg/scipy/stats/BiasedUrn.pxd> and
> biasedurn.pyx
> <https://github.com/mdhaber/scipy/blob/nchg/scipy/stats/biasedurn.pyx>.
>
> After building, this should work:
> from scipy.stats.biasedurn import _PyFishersNCHypergeometric as
> PyFishersNCHypergeometric
> n, m, N, odds, accuracy = 8, 25, 50, 5, 1e-8
> py_fnch = PyFishersNCHypergeometric(n, m, N, odds, accuracy)
> print(py_fnch.mode())
> print(py_fnch.mean())
> print(py_fnch.variance())
> print(py_fnch.probability(7))
> print(py_fnch.moments())
> (Of course, we still need to add it to stats as a proper distribution.)
>
> Thanks for your thoughts!
> Matt
>
> On Fri, Jul 24, 2020 at 7:54 AM Matt Haberland <mhaberla at calpoly.edu>
> wrote:
>
>> Funny that you should mention this now! On Tuesday we got permission from
>> Agner Fog to use his C++ implementation (used in the R package BiasedUrn,
>> https://cran.r-project.org/web/packages/BiasedUrn/index.html) under
>> SciPy's license. Would you be interested in wrapping a C++ implementation?
>>
>> On Fri, Jul 24, 2020, 2:53 AM Harry Gulliver <gulliver.harry at gmail.com>
>> wrote:
>>
>>> Hi all, new (potential) contributor here!
>>>
>>> I'm working on a project using Wallenius' non-central hypergeometric
>>> distribution atm and noticed it's not yet available in scipy.stats, so
>>> thought I'd volunteer to add it. Could possibly also do Fisher's hypergeom
>>> while I'm at it.
>>>
>>> Anything I ought to know before just writing some code and making a pull
>>> request? How can I best help?
>>>
>>> Thanks!
>>> Harry
>>> _______________________________________________
>>> SciPy-Dev mailing list
>>> SciPy-Dev at python.org
>>> https://mail.python.org/mailman/listinfo/scipy-dev
>>>
>>
>
> --
> Matt Haberland
> Assistant Professor
> BioResource and Agricultural Engineering
> 08A-3K, Cal Poly
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at python.org
> https://mail.python.org/mailman/listinfo/scipy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20200810/648ddf70/attachment-0001.html>


More information about the SciPy-Dev mailing list