summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-01-26 16:25:40 -0700
committerGitHub <noreply@github.com>2021-01-26 16:25:40 -0700
commitfd996225c5f712e7fc4e301c6e698a8a10854dd9 (patch)
tree26252340f218ab917015c35461a1536c36055082 /numpy
parent6d47dd75103b1cf90403877c091c1b6b1800c3ff (diff)
parentf7d26c28190b430407e35c2169af88935353403c (diff)
downloadnumpy-fd996225c5f712e7fc4e301c6e698a8a10854dd9.tar.gz
Merge pull request #18223 from SnoopJeDi/fix_random-generator-choice_doc
DOC: Improve doc for numpy.random.Generator.choice
Diffstat (limited to 'numpy')
-rw-r--r--numpy/random/_generator.pyx9
1 files changed, 8 insertions, 1 deletions
diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx
index 3033a1495..0a41f13b6 100644
--- a/numpy/random/_generator.pyx
+++ b/numpy/random/_generator.pyx
@@ -599,7 +599,7 @@ cdef class Generator:
"""
choice(a, size=None, replace=True, p=None, axis=0, shuffle=True)
- Generates a random sample from a given 1-D array
+ Generates a random sample from a given array
Parameters
----------
@@ -665,6 +665,13 @@ cdef class Generator:
array([3,1,0]) # random
>>> #This is equivalent to rng.permutation(np.arange(5))[:3]
+ Generate a uniform random sample from a 2-D array along the first
+ axis (the default), without replacement:
+
+ >>> rng.choice([[0, 1, 2], [3, 4, 5], [6, 7, 8]], 2, replace=False)
+ array([[3, 4, 5], # random
+ [0, 1, 2]])
+
Generate a non-uniform random sample from np.arange(5) of size
3 without replacement: