haojin2 commented on a change in pull request #16089: [Numpy] Random.choice implemented URL: https://github.com/apache/incubator-mxnet/pull/16089#discussion_r321555272
########## File path: python/mxnet/numpy/random.py ########## @@ -180,3 +180,60 @@ def multinomial(n, pvals, size=None, **kwargs): array([32, 68]) """ return _mx_nd_np.random.multinomial(n, pvals, size, **kwargs) + + +def choice(a, size=None, replace=True, p=None, ctx=None, out=None): + """Generates a random sample from a given 1-D 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, optional + 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, optional + Whether the sample is with or 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. + ctx : Context, optional + Device context of output. Default is current context. + out : ``ndarray``, optional Review comment: What's the usage of `out` here? I think you can get rid of it here. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services