Table Of Contents
Table Of Contents


mxnet.ndarray.random.exponential(scale=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs)[source]

Draw samples from an exponential distribution.

Its probability density function is

\[f(x; \frac{1}{\beta}) = \frac{1}{\beta} \exp(-\frac{x}{\beta}),\]

for x > 0 and 0 elsewhere. beta is the scale parameter, which is the inverse of the rate parameter lambda = 1/beta.

  • scale (float or NDArray, optional) – The scale parameter, beta = 1/lambda.

  • shape (int or tuple of ints, optional) – The number of samples to draw. If shape is, e.g., (m, n) and scale is a scalar, output shape will be (m, n). If scale is an NDArray with shape, e.g., (x, y), then output will have shape (x, y, m, n), where m*n samples are drawn for each entry in scale.

  • dtype ({'float16', 'float32', 'float64'}, optional) – Data type of output samples. Default is ‘float32’

  • ctx (Context, optional) – Device context of output. Default is current context. Overridden by scale.context when scale is an NDArray.

  • out (NDArray, optional) – Store output to an existing NDArray.


>>> mx.nd.random.exponential(1)
[ 0.79587454]
<NDArray 1 @cpu(0)>
>>> mx.nd.random.exponential(1, shape=(2,))
[ 0.89856035  1.25593066]
<NDArray 2 @cpu(0)>
>>> scale = mx.nd.array([1,2,3])
>>> mx.nd.random.exponential(scale, shape=2)
[[  0.41063145   0.42140478]
 [  2.59407091  10.12439728]
 [  2.42544937   1.14260709]]
<NDArray 3x2 @cpu(0)>