Help on built-in function choice:
choice(...) method of mtrand.RandomState instance
choice(a, size=None, replace=True, p=None)
Generates a random sample from a given 1-D array
.. versionadded::1.7.0
Parameters
-----------
a :1-D array-like orint
If an ndarray, a random sample is generated from its elements.
If an int, the random sample is generated asif a were np.arange(a)
size :intortuple of ints, optional
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
``m * n * k`` samples are drawn. Default isNone,in which case a
single value is returned.
replace : boolean, optional
Whether the sample iswithor without replacement
p :1-D array-like, optional
The probabilities associated with each entry in a.
If not given the sample assumes a uniform distribution over all
entries in a.
Returns
--------
samples : single item or ndarray
The generated random samples
Raises
-------
ValueError
If a is an intand less than zero,if a or p are not1-dimensional,if a is an array-like of size 0,if p isnot a vector of
probabilities,if a and p have different lengths,orif
replace=Falseand the sample size is greater than the population
size
See Also
---------
randint, shuffle, permutation
Examples
---------
Generate a uniform random sample from np.arange(5) of size 3:>>> np.random.choice(5</