diff options
author | Warren Weckesser <warren.weckesser@gmail.com> | 2019-10-18 04:12:24 -0400 |
---|---|---|
committer | Warren Weckesser <warren.weckesser@gmail.com> | 2019-10-18 04:12:24 -0400 |
commit | 8634b18abdb30629b4b869f0c81bb7a350832baa (patch) | |
tree | 81ded688d97dcca235c9e6eded5210d7d94b5919 /numpy/random/setup.py | |
parent | 9ee262b5bf89e8c866a507e4d62b78532361adc2 (diff) | |
download | numpy-8634b18abdb30629b4b869f0c81bb7a350832baa.tar.gz |
ENH: random: Add the multivariate hypergeometric distribution
The new method
multivariate_hypergeometric(self, object colors, object nsample,
size=None, method='marginals')
of the class numpy.random.Generator implements the multivariate
hypergeometric distribution; see
https://en.wikipedia.org/wiki/Hypergeometric_distribution,
specifically the section "Multivariate hypergeometric distribution".
Two algorithms are implemented. The user selects which algorithm
to use with the `method` parameter. The default, `method='marginals'`,
is based on repeated calls of the univariate hypergeometric
distribution function. The other algorithm, selected with
`method='count'`, is a brute-force method that allocates an
internal array of length ``sum(colors)``. It should only be used
when that value is small, but it can be much faster than the
"marginals" algorithm in that case.
The C implementations of the two methods are in the files
random_mvhg_count.c and random_mvhg_marginals.c in
numpy/random/src/distributions.
Diffstat (limited to 'numpy/random/setup.py')
-rw-r--r-- | numpy/random/setup.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/random/setup.py b/numpy/random/setup.py index ddb16339b..ca01250f4 100644 --- a/numpy/random/setup.py +++ b/numpy/random/setup.py @@ -100,6 +100,8 @@ def configuration(parent_package='', top_path=None): other_srcs = [ 'src/distributions/logfactorial.c', 'src/distributions/distributions.c', + 'src/distributions/random_mvhg_count.c', + 'src/distributions/random_mvhg_marginals.c', 'src/distributions/random_hypergeometric.c', ] for gen in ['_generator', '_bounded_integers']: @@ -114,7 +116,6 @@ def configuration(parent_package='', top_path=None): define_macros=defs, ) config.add_extension('mtrand', - # mtrand does not depend on random_hypergeometric.c. sources=['mtrand.c', 'src/legacy/legacy-distributions.c', 'src/distributions/logfactorial.c', |