8000 Merge pull request #13277 from kritisingh1/random · numpy/numpy@5e46e3d · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e46e3d

Browse files
authored
Merge pull request #13277 from kritisingh1/random
DOC: Document caveat in random.uniform
2 parents a86c7e5 + ea4a9fd commit 5e46e3d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

numpy/random/mtrand/mtrand.pyx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ cdef class RandomState:
12351235
greater than or equal to low. The default value is 0.
12361236
high : float or array_like of floats
12371237
Upper boundary of the output interval. All values generated will be
1238-
less than high. The default value is 1.0.
1238+
less than or equal to high. The default value is 1.0.
12391239
size : int or tuple of ints, optional
12401240
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
12411241
``m * n * k`` samples are drawn. If size is ``None`` (default),
@@ -1270,7 +1270,14 @@ cdef class RandomState:
12701270
If ``high`` < ``low``, the results are officially undefined
12711271
and may eventually raise an error, i.e. do not rely on this
12721272
function to behave when passed arguments satisfying that
1273-
inequality condition.
1273+
inequality condition. The ``high`` limit may be included in the
1274+
returned array of floats due to floating-point rounding in the
1275+
equation ``low + (high-low) * random_sample()``. For example:
1276+
1277+
>>> x = np.float32(5*0.99999999)
1278+
>>> x
1279+
5.0
1280+
12741281
12751282
Examples
12761283
--------

0 commit comments

Comments
 (0)
0