Numpy: np.random.choice()

1. Documentation:

2. Parameters:

1) a: If the input is a one-dimensional array, it will be sampled from the one-dimensional array, if it is an int type, it will be sampled randomly from the sequence from 0 to a-1.

2) size: Indicates the number of samples; it can be int type (default is 1) or tuple. If it is a tuple, such as (m,n,k), the number of samples is m* n *k, and the size is an array of (m,n,k).

3) replace: True means to take the number at random, and put it back after sampling (the same number can be drawn repeatedly), False means to take the number immediately, and not put it back after sampling (the number in the sample can only be sampled once).

4) p: a one-dimensional array, corresponding to the sampling probability of each element of the array a, and the sampling probability of each element is the same by default.
 

Guess you like

Origin blog.csdn.net/qq_40108803/article/details/114983454