summaryrefslogtreecommitdiff
path: root/numpy/random/src
Commit message (Collapse)AuthorAgeFilesLines
* CLN: Move to legacy functionKevin Sheppard2021-02-262-18/+79
| | | | | | Avoid conditional compilation and move old version to legacy_vonmises Small clean up Additional comments
* BUG: Prevent RandomState from changingKevin Sheppard2021-02-261-7/+13
| | | | | | | | Apply vonmises fix only to Generator Add tests for correctness closes #17378 closes #17275
* Fixed style and added check for bounds in [-pi,pi] interval.Raúl Montón Pinillos2021-02-261-6/+17
|
* Fixed Von Mises distribution for big values of kappa by falling back to a ↵Raúl Montón Pinillos2021-02-261-3/+8
| | | | normal distribution (which the von mises distribution converges to).
* MAINT: Correct code producing warningsKevin Sheppard2021-02-181-1/+1
| | | | | Cast to avoid warnings Correct function
* BLD: Enable Werror=undef in travisSayed Adel2020-11-171-3/+3
|
* MAINT: precompute log(2.0 * M_PI) in `random_loggam' (gh-16237)Elia Franzella2020-05-191-10/+12
| | | | Most compilers should optimize it, but it doesn't hurt to inline and has a better name now.
* MAINT: Remove unused fileKevin Sheppard2020-05-121-215/+0
| | | | Remove unused file containing the old polynomial representation.
* REF: Refactor jump codeKevin Sheppard2020-05-123-116/+143
| | | | | | Refactor polynomial to be unsigned long array Remove unused code Fix md5 calculation on BE
* BUG: Correct loop order in MT19937 jumpKevin Sheppard2020-05-122-3/+9
| | | | | | Use the original loop order instead of an inverted order closes #15394
* MAINT: random: Add assert() statements.Warren Weckesser2020-04-261-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-261-11/+31
| | | | | | | | | | | | 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.
* BLD: use 0.3.7 release version, add dependency on libgfortran5mattip2020-01-172-2/+2
|
* Fix typos, via a Levenshtein-style correctorBrian Wignall2019-12-191-1/+1
|
* API, DOC: change names to multivariate_hypergeometric, improve docsmattip2019-12-042-4/+4
|
* API: revert changes to standard_t, cauchymattip2019-11-301-2/+2
|
* API: rename functions in distributions.c,hmattip2019-11-291-46/+39
|
* API: restructure and document numpy.random C-API (#14604)Matti Picus2019-11-194-4/+4
| | | | | | | | | | | | | | | | * 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
* BUG: random: biased samples from integers() with 8 or 16 bit dtype.Warren Weckesser2019-10-241-14/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-182-0/+269
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* API: remove unused functions from distributions.hmattip2019-10-112-7/+19
|
* API: refactor function names in distribution.{h,c}, refactor float_fillmattip2019-10-112-211/+72
|
* API: rearrange the cython files in numpy.randommattip2019-10-118-349/+3
|
* BLD: remove unused functions, rearrange headers (from CC=clang) (#14534)Matti Picus2019-09-264-6/+5
| | | | | * BUILD: remove unused functions, rearrange headers (from CC=clang) * MAINT: check enum at API call, not in provate function
* MAINT: don't install partial numpy.random C/Cython API.Ralf Gommers2019-09-212-1/+21
| | | | | | | | | See https://mail.python.org/pipermail/numpy-discussion/2019-September/080088.html for discussion. We need to do this right, and add tests and docs. All this PR does is not install bitgen.h, common.pxd and bit_generator.pxd (they're still shipped in the sdist, that is needed). Should be backported to 1.17.x
* BUG: random: Create a legacy implementation of random.binomial.Warren Weckesser2019-09-164-6/+49
| | | | | | | | | Create a legacy implementation of the random_binomial method of RandomState that does not include the "short-circuit" check for n == 0 or p == 0. This ensures that the stream of variates is consistent with the behavior in 1.16. Closes gh-14522.
* MAINT: random: Remove a few duplicated C function prototypes.Warren Weckesser2019-09-151-5/+0
|
* Merge pull request #14498 from mattip/random-namespaceRalf Gommers2019-09-152-128/+0
|\ | | | | MAINT: remove the entropy c-extension module
| * MAINT: remove the entropy c-extension modulemattip2019-09-132-128/+0
| |
* | BUG: Fix randint when range is 2**32Kevin Sheppard2019-09-141-2/+2
|/ | | | | | Fix randint to use 32-bit path when range is exactly 2**32 closes #14189
* BUG: do not force emulation of 128-bit arithmetic.Robert Kern2019-06-272-9/+20
|
* MAINT: move location of bitgen.hmattip2019-06-272-19/+1
|
* Merge pull request #13837 from mattip/seedsequence2Charles Harris2019-06-261-1/+1
|\ | | | | MAINT, BUG: fixes from seedsequence
| * BUG: fix PCG64 ng->inc.high initializationmattip2019-06-261-1/+1
| |
* | ENH: Add SFC64 BitGenerator.Robert Kern2019-06-253-0/+126
|/
* ENH: use SeedSequence to generate entropy for seedingmattip2019-06-263-12/+19
|
* MAINT: remove xoshiro* BitGeneratorsmattip2019-06-2612-570/+0
|
* MAINT: remove ThreeFry BitGeneratormattip2019-06-257-596/+1
|
* MAINT: remove pcg32 BitGeneratormattip2019-06-256-2469/+0
|
* MAINT: Correct intrinsic use on WindowsKevin Sheppard2019-06-211-0/+4
| | | | Add pragme and include for Windows PCG64
* Merge pull request #13791 from mattip/remove-dSFMTCharles Harris2019-06-2015-2157/+0
|\ | | | | MAINT: remove dSFMT
| * MAINT: remove dSFMTmattip2019-06-1615-2157/+0
| |
* | Merge pull request #13786 from WarrenWeckesser/random-warningsMatti Picus2019-06-183-6/+8
|\ \ | |/ |/| MAINT: random: Fix a few compiler warnings.
| * MAINT: random: Fix a few compiler warnings.Warren Weckesser2019-06-143-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: gcc: numpy/random/src/xoshiro256/xoshiro256.c numpy/random/src/xoshiro256/xoshiro256.c:39:16: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare] for (i = 0; i < sizeof JUMP / sizeof *JUMP; i++) ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ gcc: numpy/random/src/xoshiro512/xoshiro512.c numpy/random/src/xoshiro512/xoshiro512.c:43:17: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare] for (i = 0; i < sizeof JUMP / sizeof *JUMP; i++) ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ numpy/random/src/xoshiro512/xoshiro512.c:46:23: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare] for (w = 0; w < sizeof s_placeholder / sizeof *s_placeholder; w++) ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcc: numpy/random/src/distributions/distributions.c numpy/random/src/distributions/distributions.c:185:14: warning: comparison of integers of different signs: 'int64_t' (aka 'long long') and 'const uint64_t' (aka 'const unsigned long long') [-Wsign-compare] if (rabs < ki_double[idx]) ~~~~ ^ ~~~~~~~~~~~~~~ numpy/random/src/distributions/distributions.c:230:14: warning: comparison of integers of different signs: 'int32_t' (aka 'int') and 'const uint32_t' (aka 'const unsigned int') [-Wsign-compare] if (rabs < ki_float[idx]) ~~~~ ^ ~~~~~~~~~~~~~
* | MAINT: random: Rewrite the hypergeometric distribution.Warren Weckesser2019-06-146-106/+550
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary of the changes: * Move the functions random_hypergeometric_hyp, random_hypergeometric_hrua and random_hypergeometric from distributions.c to legacy-distributions.c. These are now the legacy implementation of hypergeometric. * Add the files logfactorial.c and logfactorial.h, containing the function logfactorial(int64_t k). * Add the files random_hypergeometric.c and random_hypergeometric.h, containing the function random_hypergeometric (the new implementation of the hypergeometric distribution). See more details below. * Fix two tests in numpy/random/tests/test_generator_mt19937.py that used values returned by the hypergeometric distribution. The new implementation changes the stream, so those tests needed to be updated. * Remove another test obviated by an added constraint on the arguments of hypergeometric. Details of the rewrite: If you carefully step through the old function rk_hypergeometric_hyp(), you'll see that the end result is basically the same as the new function hypergeometric_sample(), but the new function accomplishes the result with just integers. The floating point calculations in the old code caused problems when the arguments were extremely large (explained in more detail in the unmerged pull request https://github.com/numpy/numpy/pull/9834). The new version of hypergeometric_hrua() is a new translation of Stadlober's ratio-of-uniforms algorithm for the hypergeometric distribution. It fixes a mistake in the old implementation that made the method less efficient than it could be (see the details in the unmerged pull request https://github.com/numpy/numpy/pull/11138), and uses a faster function for computing log(k!). The HRUA algorithm suffers from loss of floating point precision when the arguments are *extremely* large (see the comments in github issue 11443). To avoid these problems, the arguments `ngood` and `nbad` of hypergeometric must be less than 10**9. This constraint obviates an existing regression test that was run on systems with 64 bit long integers, so that test was removed.
* MAINT: random: Combine ziggurat.h and ziggurat_constants.hWarren Weckesser2019-06-123-277/+10
| | | | ... and remove the unused arrays that were in ziggurat.h.
* MAINT: random: Rename legacy distributions file.Warren Weckesser2019-06-092-1/+1
| | | | | | In numpy/random/src/legacy/, rename distributions-boxmuller.c to legacy-distributions.c. This file holds all the legacy distributions, so the new name is more accurate.
* MAINT: random: Remove unused empty file binomial.h.Warren Weckesser2019-06-081-0/+0
| | | | The file numpy/random/src/distributions/binomial.h was empty and unused.
* Merge pull request #13665 from bashtage/rkern-pcg-patchMatti Picus2019-05-311-7/+25
|\ | | | | MAINT: Use intrinsics in Win64-PCG64
| * PERF: Use intrinsics in Win64-PCG64Kevin Sheppard2019-05-311-7/+25
| | | | | | | | Use intrinsics to speed up PCG64 on Windows 64