numpy.random.choice(a, size=None, replace=True, p=None)
可以从一个int数字或1维array里随机选取内容,并将选取结果放入n维array中返回。
Parameters:a: 1-D array-like or int
If an ndarray, a random sample is generated from its elements. If an int, the random sample is generated as if a were np.arange(a)size: int or tuple of ints,可选参数
Output shape. If the given shape is, e.g.,(m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.
replace: boolean,可选参数
Whether the sample is with or without replacement
p: 1-D array-like, 可选参数
The probabilities associated with each entry in a. If not given the sample assumes a uniform distribution over all entries in a.