You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/10/07 07:46:26 UTC

[GitHub] anirudhacharya commented on a change in pull request #12749: [MXNET-1029] Feature request: randint operator

anirudhacharya commented on a change in pull request #12749: [MXNET-1029] Feature request: randint operator
URL: https://github.com/apache/incubator-mxnet/pull/12749#discussion_r223203436
 
 

 ##########
 File path: python/mxnet/ndarray/random.py
 ##########
 @@ -518,3 +518,47 @@ def shuffle(data, **kwargs):
     <NDArray 2x3 @cpu(0)>
     """
     return _internal._shuffle(data, **kwargs)
+
+
+def randint(low=0, high=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
+    """Draw random samples from a discrete uniform distribution.
+
+    Samples are uniformly distributed over the half-open interval *[low, high)*
+    (includes *low*, but excludes *high*).
+
+    Parameters
+    ----------
+    low : float or NDArray
+        Lower boundary of the output interval. All values generated will be
+        greater than or equal to low. The default value is 0.
+    high : float or NDArray
+        Upper boundary of the output interval. All values generated will be
+        less than high. The default value is 1.
+    shape : int or tuple of ints
+        The number of samples to draw. If shape is, e.g., `(m, n)` and `low` and
+        `high` are scalars, output shape will be `(m, n)`. If `low` and `high`
+        are NDArrays with shape, e.g., `(x, y)`, then output will have shape
+        `(x, y, m, n)`, where `m*n` samples are drawn for each `[low, high)` pair.
 
 Review comment:
   this behavior of the `randint` operator seems weird. 
   
   Why are we not mimicking the behavior of [`numpy.random.randint`](https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.random.randint.html) function. Even pytorch's [`torch.randperm`](https://pytorch.org/docs/0.3.1/torch.html?highlight=torch%20random#torch.randperm) is defined similarly.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services