summaryrefslogtreecommitdiff
path: root/numpy/random
Commit message (Collapse)AuthorAgeFilesLines
* TST: random: Skip a test if integers are 32 bit.Warren Weckesser2020-04-271-0/+2
|
* TST: random: Add more repeatability tests for random integers.Warren Weckesser2020-04-272-0/+45
| | | | | | | Add repeatability tests for when the range of the integers is `2**32` (and `2**32 +/- 1` for good measure) with broadcasting. The underlying functions called by Generator.integers and random.randint when the inputs are broadcast are different than when the inputs are scalars.
* MAINT: random: Add assert() statements.Warren Weckesser2020-04-271-0/+11
| | | | | Assert that an invalid value (2**n-1 for n = 8, 16, 32, 64) has not been passed to the Lemire function.
* BUG: random: Generator.integers(2**32) always returned 0.Warren Weckesser2020-04-272-11/+46
| | | | | | | | | | | | When the input to Generator.integers was 2**32, the value 2**32-1 was being passed as the `rng` argument to the 32-bit Lemire method, but that method requires `rng` be strictly less then 2**32-1. The fix was to handle 2**32-1 by calling next_uint32 directly. This also works for the legacy code without changing the stream of random integers from `randint`. Closes gh-16066.
* Merge pull request #16017 from charris/backport-15951Charles Harris2020-04-194-18/+32
|\ | | | | BUG: Alpha parameter must be 1D in `generator.dirichlet`
| * BUG: Alpha parameter must be 1D in `generator.dirichlet` (#15951)panpiort82020-04-194-18/+32
| | | | | | | | | | | | | | | | | | Only one dimensional alpha paramter is currently supported, but higher dimensions were silently allowed and gave an incorrect results. This fixes the regression. In the future, the API could be extended to allow higher dimensional arrays for alpha. Fixes gh-15915
* | Add minor tests enhancementPan Jan2020-04-112-2/+2
| |
* | Replace checks with direct function callPan Jan2020-04-112-8/+4
| |
* | Add testing and replace checkPan Jan2020-04-114-4/+16
| |
* | BUG: add check if pvals is 1d array in numpy.random.*.multinomialPan Jan2020-04-112-0/+4
|/
* Bug: Fix eigh mnd cholesky methods of numpy.random.multivariate_normalMax Balandat2020-04-062-3/+26
| | | | Fixes #15871
* Documentation updated.przemb2020-03-012-31/+22
|
* Changes suggested in reviewprzemb2020-03-013-16/+11
|
* MAINT: Large overhead in some random functions #15460przemb2020-03-013-59/+53
| | | | | | | | | | | | | | slow calls to np.dtype.name replaced with np.dtype, mtrand.pyx and _generator.pyx updated, test test_warns_byteorder updated before: %timeit rs.random(): 520 ns ± 33.1 ns per loop %timeit rg.random(): 6.36 µs ± 222 ns per loop after: %timeit rs.random(): 453 ns ± 6.95 ns per loop %timeit rg.random(): 594 ns ± 9.66 ns per loop
* MAINT: remove dead code from reviewmattip2020-01-021-2/+2
|
* MAINT: unskip test on win32mattip2020-01-012-3/+2
|
* BUG: use tmp dir and check version for cython test (#15170)Matti Picus2019-12-262-17/+28
| | | | | | | | | | | | * BUG: use tmp dir and check version for cython test * TST, MAINT: skip on win32, fix formatting * TST: fixes from review * TST: fixes from review * TST: fixes from review
* API, DOC: change names to multivariate_hypergeometric, improve docsmattip2019-12-053-12/+12
|
* REV: Revert "Merge pull request #14794 from mattip/nep-0034-impl"Charles Harris2019-12-043-10/+7
| | | | | | | | This reverts commit 3a9a63f81aa37b48bc3eb4efdc2e695210805aa5, reversing changes made to 7999f7c038a50d79b06edf2d45eb5ff2c25a5a42. A lot of problems have been exposed by this change, so best to leave it out of the 1.18.x series and work on it in master.
* Merge pull request #15007 from mattip/random-c-api2Ralf Gommers2019-12-034-89/+94
|\ | | | | DOC, API: improve the C-API/Cython documentation and interfaces for random
| * API: revert changes to standard_t, cauchymattip2019-11-302-6/+6
| |
| * API: rename functions in distributions.c,hmattip2019-11-292-60/+51
| |
| * DOC, TST: refactor CFFI test, add file names to documentationmattip2019-11-292-35/+49
| |
* | Merge pull request #14794 from mattip/nep-0034-implRalf Gommers2019-12-023-7/+10
|\ \ | |/ |/| DEP: issue deprecation warning when creating ragged array (NEP 34)
| * MAINT: revert change to assert_array_equal, adjust testsmattip2019-10-313-3/+6
| |
| * DEP: issue deprecation warning when creating ragged array (NEP 34)mattip2019-10-313-4/+4
| |
* | Merge pull request #14954 from mattip/test-extending-cffiCharles Harris2019-11-274-5/+97
|\ \ | | | | | | TST. API: test using distributions.h via cffi
| * | TST: skip cffi tests when PYTHONOPTIMIZE>1, pycparser failsmattip2019-11-212-0/+12
| | |
| * | API, MAINT: export symbols on MSVC, fix typosmattip2019-11-211-3/+3
| | |
| * | TST. API: test using distributions.h via cffimattip2019-11-212-2/+82
| | |
* | | Merge pull request #14948 from mattip/document-randomCharles Harris2019-11-2712-25/+315
|\ \ \ | | | | | | | | DOC, API: add random.__init__.pxd and document random.* functions
| * | | DOC: update note from reviewmattip2019-11-211-84/+84
| | | |
| * | | MAINT: "See also" -> "See Also"mattip2019-11-211-23/+23
| | | |
| * | | DOC, API: add numpy.random.__index__.pxd and document numpy.random.* funcsmattip2019-11-2112-25/+315
| | | |
* | | | TST: skip if cython is not availablemattip2019-11-221-0/+6
|/ / /
* | | DOC: Clean up examples of low-level random accessKevin Sheppard2019-11-214-21/+37
|/ / | | | | | | | | | | Test examples on Linux and Windows Correct bug in Cython example Improve building instructions for numba examples
* | DOC, MAINT: fix documentation, remove __init__.pymattip2019-11-201-0/+0
| |
* | MAINT: move numpy/random/examples -> numpy/random/_examplesmattip2019-11-198-4/+4
| |
* | DOC: Clarify return type for default rngKevin Sheppard2019-11-191-3/+7
| | | | | | | | Ensure that default_rng has a return type to improve code completion
* | API: restructure and document numpy.random C-API (#14604)Matti Picus2019-11-1918-298/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * API: restructure and document numpy.random C-API * DOC: fix bad reference * API: ship, document, and start to test numpy.random C-API examples * API, DOC, TST: fix tests, refactor documentation to include snippets * BUILD: move public headers to numpy/core/include/numpy/random * TST: ignore DeprecationWarnings in setuptools and numba * DOC: document the C-API as used from Cython
* | Merge pull request #14878 from mattip/remove-sse2Warren Weckesser2019-11-141-5/+0
|\ \ | | | | | | BUILD: remove SSE2 flag from numpy.random builds
| * | BUILD: remove SSE2 flag from numpy.random buildsmattip2019-11-111-5/+0
| | |
* | | MAINT: Remove uses of scalar aliasesEric Wieser2019-11-137-32/+31
| | | | | | | | | | | | Relates to gh-6103
* | | MAINT: Delete and ignore generated filesEric Wieser2019-11-133-1593/+3
|/ /
* | merge latest changes on master branchRedRuM2019-11-0341-997/+3010
|\ \ | |/
| * DOC: random: Remove redundant 'See Also' entry in 'uniform' docstring.Warren Weckesser2019-10-281-1/+0
| |
| * BUG: random: biased samples from integers() with 8 or 16 bit dtype.Warren Weckesser2019-10-242-16/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an 8 or 16 bit dtype was given to the integers() method of the Generator class, the resulting sample was biased. The problem was the lines of the form const uint8_t threshold = -rng_excl % rng_excl; in the implementations of Lemire's method, in the C file distributions.c. The intent was to compute (UINT8_MAX+1 - rng_excl) % rng_excl However, when the type of rng_excl has integer conversion rank lower than a C int (which is almost certainly the case for the 8 and 16 bit types), the terms in the expression -rng_excl % rng_excl are promoted to int, and the result of the calculation is always 0. The fix is to make the expression explicit, and write it as const uint8_t threshold = (UINT8_MAX - rng) % rng_excl; rng is used, because rng_excl is simply rng + 1; by using rng, we we only need the constant UINT#_MAX, without the extra +1. For consistency, I made the same change for all the data types (8, 16, 32 and 64 bit). Closes gh-14774.
| * ENH: random: Add the multivariate hypergeometric distributionWarren Weckesser2019-10-186-3/+668
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * DOC: fix from reviewmattip2019-10-171-1/+1
| |
| * TEST, DOC: fixes from reviewmattip2019-10-171-1/+1
| |