summaryrefslogtreecommitdiff
path: root/numpy/random
Commit message (Collapse)AuthorAgeFilesLines
* BUG: Ensure SeedSequence 0-padding does not collide with spawn keysRobert Kern2020-06-092-2/+37
| | | | | | | | | | | | | Fixes #16539 The implicit 0-padding that is done to small entropy inputs to make them the size of the internal pool conflicts with the spawn keys, which start with an appended 0. In order to maintain stream compatibility with unspawned `SeedSequence`s, we explicitly 0-pad short inputs out to the pool size only if the spawn key is provided, and thus would trigger the bug. This should minimize the impact on users that were not encountering the bug.
* Merge pull request #16504 from bashtage/doc-mv-normCharles Harris2020-06-081-1/+2
|\ | | | | DOC: Correct MV Normal sig
| * DOC: Correct MV Normal sigKevin Sheppard2020-06-051-1/+2
| | | | | | | | Add new kw arg to sig
* | Merge pull request #16510 from madphysicist/patch-1Charles Harris2020-06-081-1/+1
|\ \ | | | | | | DOC: Minor rounding correction in Generator.binomial
| * | DOC: Minor rounding correction in Generator.binomialJoseph Fox-Rabinovitz2020-06-061-1/+1
| |/ | | | | Changed 38.88 from 38 to 39
* | BUG: Fix cython warning in random/_common.pyx.Charles Harris2020-06-071-1/+2
| | | | | | | | | | Fix for #16508. Cython wants every pointer declaration to be on a separate line.
* | BUG: Correct broadcasting when size is not NoneKevin Sheppard2020-06-052-0/+70
|/ | | | | | | Broadcastable size with inputs does not produce an error when size produces a smaller output array than the broadcast input shape. Patch checks that the output shape matches the outer shape of the broadcast fo all inputs and the size when given.
* DEP: Deprecate passing shape=None to mean shape=()Eric Wieser2020-05-312-12/+18
| | | | This requires some minor tweaks in `np.random` because there the two have different meanings, with `()` meaning 0d array and `None` meaning scalar.
* 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.
* Merge pull request #16156 from WarrenWeckesser/deprecate-dualSebastian Berg2020-05-192-4/+4
|\ | | | | DEP: Deprecate `numpy.dual`.
| * DEP: Deprecate `numpy.dual`.Warren Weckesser2020-05-042-4/+4
| | | | | | | | | | | | Add a deprecation warning in the `numpy.dual` module, and remove the use of `numpy.dual` from the few places where it is used in the numpy code.
* | Merge pull request #16153 from bashtage/fix-mt19937-jumpCharles Harris2020-05-136-329/+210
|\ \ | | | | | | BUG: Correct loop order in MT19937 jump
| * | DOC: Update docstringKevin Sheppard2020-05-121-4/+3
| | | | | | | | | | | | Fix indent on reference and remove text that may be incorrect.
| * | DOC: Improve the docstring for MT19937.jumpedKevin Sheppard2020-05-121-0/+18
| | | | | | | | | | | | Clarify the method used and the source of the code
| * | MAINT: Remove unused fileKevin Sheppard2020-05-121-215/+0
| | | | | | | | | | | | Remove unused file containing the old polynomial representation.
| * | REF: Refactor jump codeKevin Sheppard2020-05-124-121/+154
| | | | | | | | | | | | | | | | | | Refactor polynomial to be unsigned long array Remove unused code Fix md5 calculation on BE
| * | BUG: Correct loop order in MT19937 jumpKevin Sheppard2020-05-123-6/+52
| | | | | | | | | | | | | | | | | | Use the original loop order instead of an inverted order closes #15394
* | | DOC: Fix Generator.choice docstringKevin Sheppard2020-05-132-2/+2
|/ / | | | | | | | | Remove trailing colon Fix indentation in RandomState choice doc string
* | Merge pull request #16162 from mattip/add-pxdCharles Harris2020-05-071-3/+13
|\ \ | | | | | | BUG: add missing numpy/__init__.pxd to the wheel
| * | TST: add tag to __init__.pxd and test that the tag is foundmattip2020-05-061-3/+13
| | |
* | | Mark tests as a subpackage rather than data.Hameer Abbasi2020-05-061-1/+2
| |/ |/|
* | MAINT: Fix random.PCG64 signature in its docstring (#16113)ndunnewind2020-04-291-1/+1
| |
* | BUG: Fix numpy.random.dirichlet returns NaN for small 'alpha' parameters. ↵Benjamin Trendelkamp-Schroer2020-04-292-13/+97
|/ | | | | | | | | | | | | | | (#14924) * Add stick-breaking * Add tests demonstrating slowness for beta and dirichlet generators for small alpha (and beta) values * Remove the test for beta with small `a` and `b` * Switch from standard to stick-breaking method whenever alpha.max() < 0.1 Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* 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-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-262-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.
* DOC: add a note on sampling 2-D arrays to random.choice docstringRalf Gommers2020-04-251-0/+5
| | | | Addresses a comment on gh-10835.
* BUG: missing 'f' prefix for fstringmattip2020-04-221-1/+1
|
* BUG: Alpha parameter must be 1D in `generator.dirichlet` (#15951)panpiort82020-04-184-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
* Merge pull request #15876 from panpiort8/multinomial_pvals_1dMatti Picus2020-04-114-4/+16
|\ | | | | BUG: Check that `pvals` is 1D in `_generator.multinomial`.
| * Add minor tests enhancementPan Jan2020-04-062-2/+2
| |
| * Replace checks with direct function callPan Jan2020-04-012-8/+4
| |
| * Add testing and replace checkPan Jan2020-04-014-4/+16
| |
| * BUG: add check if pvals is 1d array in numpy.random.*.multinomialPan Jan2020-03-312-0/+4
| |
* | Typo in the `mtrand.pyx` was fixedAndrei Shirobokov2020-04-081-1/+1
| | | | | | | | `ValueError` about negative dimension was lowercased.
* | BUG: random: Disallow p=0 in negative_binomialWarren Weckesser2020-04-052-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | Make `Generator.negative_binomial` raise a ValueError if p=0. `negative_binomial(n, p)` draws samples from the distribution of the number of failures until n successes are encountered. If p is 0, then a success is never encountered, so the probability distribution is 0 for any finite number of failures. In other words, it is not really a meaningful distribution, so we disallow p=0. Closes gh-15913.
* | Bug: Fix eigh mnd cholesky methods of numpy.random.multivariate_normalMax Balandat2020-04-042-3/+26
|/ | | | Fixes #15871
* MAINT: simplify code that assumes str/unicode and int/long are different ↵Eric Wieser2020-03-263-24/+0
| | | | | types (#15816) Cleanup from the dropping of python 2
* BUG: add missing c_distributions.pxd, enables cython use of random C-API ↵Matti Picus2020-03-1611-149/+244
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (gh-15463) xref gh-14778 As pointed out in the comment by @jamesthomasgriffin, we did not include a pxd file to expose the distribution functions documented in the random c-api. This PR adds a c_distributions.pxd file that exposes them. Squashed commits: * BUG: add missing c_distributions.pxd to enable cython use of random C-API * ENH, TST: add npyrandom library like npymath, test cython use of it * BUG: actually prefix f-string with f * MAINT: fixes from review, add _bit_generato_bit_generator.pxd * STY: fixes from review * BLD: don't use nprandom library for mtrand legacy build * TST: WindowsPath cannot be used in subprocess's list2cmdline * MAINT, API: move _bit_generator to bit_generator * DOC: add release note about moving bit_generator * DOC, MAINT: fixes from review * MAINT: redo dtype determination from review
* convert shebang from python to python3 (#15687)Changqing Li2020-03-042-2/+2
| | | | Signed-off-by: Changqing Li <changqing.li@windriver.com>
* BUG: fix doctest exception messagesmattip2020-02-281-1/+1
|
* DOC: Document caveat in random.uniformmattip2020-02-151-2/+9
|
* Merge pull request #15465 from mwtoews/importsSebastian Berg2020-02-071-2/+2
|\ | | | | MAINT: cleanup unused imports; avoid redefinition of imports
| * MAINT: cleanup unused imports; avoid redefinition of importsMike Taves2020-02-061-2/+2
| | | | | | | | | | | | | | * Cleanup unused imports (F401) of mostly standard Python modules, or some internal but unlikely referenced modules * Where internal imports are potentially used, mark with noqa * Avoid redefinition of imports (F811)
* | Documentation updated.przemb2020-02-062-31/+22
| |
* | Changes suggested in reviewprzemb2020-02-053-16/+11
| |
* | MAINT: Large overhead in some random functions #15460przemb2020-02-053-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
* DOC: Correct get_state docKevin Sheppard2020-01-311-5/+7
| | | | Move flag to parameters
* STY,MAINT: avoid 'multiple imports on one line' (flake8 E401)Mike Taves2020-01-281-2/+3
| | | | | | * PEP 8: "Imports should usually be on separate lines" * Where modified, sort imported modules alphabetically * Clean-up unused imports from these expanded lines