| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
| |
In C, when the integer part of a double exceeds the maximum int64, casting
the double to int64_t is undefined behavior. On some platforms, the result
is 2**64-1 and on others it is -2**64. That results in rng.geometric()
returning -2**64 when p was sufficiently small on some platforms.
The fix is to never invoke undefined behavior by ensuring we don't attempt
to cast very large double values to int64_t.
|
|
|
|
| |
Closes gh-22100
|
|
|
|
|
|
|
|
|
| |
This seems to have been removed by accident in #21887
stdlib.h is required for _rotr64() further down.
Fixes:
error: call to undeclared function '_rotr64'; ISO C99 and later do not support
implicit function declarations [-Wimplicit-function-declaration]
|
|
|
|
|
| |
[ci skip]
Co-authored-by: h-vetinari <h.vetinari@gmx.com>
|
|
|
|
|
|
|
| |
Macro `__MINGW32__` always defined for Mingw-w64 compilers (32- or
64-bit):
https://sourceforge.net/p/predef/wiki/Compilers/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The formula to convert a 32 bit random integer to a random float32,
(next_uint32(bitgen_state) >> 9) * (1.0f / 8388608.0f)
shifts by one bit too many, resulting in uniform float32 samples always
having a 0 in the least significant bit. The formula is corrected to
(next_uint32(bitgen_state) >> 8) * (1.0f / 16777216.0f)
Occurrences of the incorrect formula in numpy/random/tests/test_direct.py
were also corrected.
Closes gh-17478.
|
|
|
|
|
|
|
| |
Correct incorrect implemetation of carry in PCG64 and PCG64DXSM
when advancing more than 2**64 steps
closes #20048
|
|
|
| |
* Fix typos
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* add support for windows on arm targets
* Philox: Use _umulh intrinsic for ARM64 target
* CPU Detection: Refactor to avoid separate pre-processor definition for WoA
* adapt test_dragon4 to avoid using pow (**) to workaround issue in windows C RT for arm64
* Update numpy/core/include/numpy/npy_cpu.h
Co-authored-by: Matti Picus <matti.picus@gmail.com>
* add release note for numpy windows/arm64 support
* Update 19513.new_feature.rst
Co-authored-by: Matti Picus <matti.picus@gmail.com>
Co-authored-by: Charles Harris <charlesr.harris@gmail.com>
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Use exponentials rather than generating exponentials via inversion
|
|
|
|
|
|
|
| |
Use log1p(-x) instead of log(1 - x)
Seperate legacy version from current
closes #17020
|
|
|
|
| |
This reduces the number of cases when floating point precision makes the argument to `log` become `0`
|
|
|
|
|
|
| |
Avoid conditional compilation and move old version to legacy_vonmises
Small clean up
Additional comments
|
|
|
|
|
|
|
|
| |
Apply vonmises fix only to Generator
Add tests for correctness
closes #17378
closes #17275
|
| |
|
|
|
|
| |
normal distribution (which the von mises distribution converges to).
|
|
|
|
|
| |
Cast to avoid warnings
Correct function
|
| |
|
|
|
|
| |
Most compilers should optimize it, but it doesn't hurt to inline and has a better name
now.
|
|
|
|
| |
Remove unused file containing the old polynomial representation.
|
|
|
|
|
|
| |
Refactor polynomial to be unsigned long array
Remove unused code
Fix md5 calculation on BE
|
|
|
|
|
|
| |
Use the original loop order instead of an inverted order
closes #15394
|
|
|
|
|
| |
Assert that an invalid value (2**n-1 for n = 8, 16, 32, 64) has not
been passed to the Lemire function.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
* BUILD: remove unused functions, rearrange headers (from CC=clang)
* MAINT: check enum at API call, not in provate function
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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: remove the entropy c-extension module
|
| | |
|
|/
|
|
|
|
| |
Fix randint to use 32-bit path when range is exactly 2**32
closes #14189
|
| |
|
| |
|
|\
| |
| | |
MAINT, BUG: fixes from seedsequence
|