[Learning] numpy random.choice () function

 np.random.choice () function

choice (a, size = None, replace = True, p = None): the given function from 1-dimensional array of random sampling.
  •  a: If a one-dimensional array, it means that from this one-dimensional array of random sampling; if int type, it represents a random sample from 0 to a-1 in this sequence.
  • size: the number of sampling results, the default is 1 may be an integer representing the number to be sampled; may be a tuple, such as (m, n, k), the number of samples will have to m * n * k, size of ( m, n, k).
  • replace: boolean type, sampling sample if you want to replace? I do not quite understand this place, test a little discovery replace designated to True, the sampling elements will be repeated; when replace designated as False, the sample will not be repeated.
  • p: a one-dimensional array, the probability of developing a sample for each element, the same as if the default probability None, each element is a sampled.
     
Published 83 original articles · won praise 14 · views 30000 +

Guess you like

Origin blog.csdn.net/weixin_38121168/article/details/103158620
Recommended