diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-02-15 15:03:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-15 15:03:58 -0800 |
commit | 2eedaa4cf94cf54bbd4d8428aa39271410f22e9f (patch) | |
tree | 5706fc4fbf5c4c8911ec5a31426a72b81ddccfdd | |
parent | 0437b83a931c5cc24296deecaa52d825e4d377e1 (diff) | |
parent | ca1b13224ba397ac3f77f48c899e2adcea1de5db (diff) | |
download | numpy-2eedaa4cf94cf54bbd4d8428aa39271410f22e9f.tar.gz |
Merge pull request #15575 from mattip/redo-13277
DOC: Document caveat in random.uniform
-rw-r--r-- | numpy/random/mtrand.pyx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/numpy/random/mtrand.pyx b/numpy/random/mtrand.pyx index 3d0318752..6387814c8 100644 --- a/numpy/random/mtrand.pyx +++ b/numpy/random/mtrand.pyx @@ -1017,7 +1017,7 @@ cdef class RandomState: greater than or equal to low. The default value is 0. high : float or array_like of floats Upper boundary of the output interval. All values generated will be - less than high. The default value is 1.0. + less than or equal to high. The default value is 1.0. size : int or tuple of ints, optional Output shape. If the given shape is, e.g., ``(m, n, k)``, then ``m * n * k`` samples are drawn. If size is ``None`` (default), @@ -1053,7 +1053,14 @@ cdef class RandomState: If ``high`` < ``low``, the results are officially undefined and may eventually raise an error, i.e. do not rely on this function to behave when passed arguments satisfying that - inequality condition. + inequality condition. The ``high`` limit may be included in the + returned array of floats due to floating-point rounding in the + equation ``low + (high-low) * random_sample()``. For example: + + >>> x = np.float32(5*0.99999999) + >>> x + 5.0 + Examples -------- |