choice#
- named_arrays.random.choice(a, p=None, axis=None, replace=True, shape_random=None, seed=None)#
Draw random samples from a given array of choices.
- Parameters:
a (ChoicesT) – An array of choices to randomly sample.
p (ProbabilityT) – An optional list of probabilities for each element in a.
axis (None | str | Sequence[str]) – The axes of a and p to flatten into a sequence of choices. This is useful if the axes of a or p intersect with the axes of shape_random.
replace (bool) – Whether the sample is drawn with or without replacement. Default is
True, meaning each value in a can be selected multiple times.shape_random (None | dict[str, int]) – Additional dimensions to be broadcast against a and p.
seed (None | int) – Optional seed for the random number generator, can be provided for repeatability.
- Return type:
ChoicesT | ProbabilityT
See also
numpy.random.choice()Equivalent numpy function