# mxnet.ndarray.random.negative_binomial¶

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

Draw random samples from a negative binomial distribution.

Samples are distributed according to a negative binomial distribution parametrized by k (limit of unsuccessful experiments) and p (failure probability in each experiment). Samples will always be returned as a floating point data type.

Parameters
• k (float or NDArray, optional) – Limit of unsuccessful experiments, > 0.

• p (float or NDArray, optional) – Failure probability in each experiment, >= 0 and <=1.

• shape (int or tuple of ints, optional) – The number of samples to draw. If shape is, e.g., (m, n) and k and p are scalars, output shape will be (m, n). If k and p 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 [k, p) pair.

• 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 k.context when k is an NDArray.

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

Examples

>>> mx.nd.random.negative_binomial(10, 0.5)
[ 4.]
<NDArray 1 @cpu(0)>
>>> mx.nd.random.negative_binomial(10, 0.5, shape=(2,))
[ 3.  4.]
<NDArray 2 @cpu(0)>
>>> k = mx.nd.array([1,2,3])
>>> p = mx.nd.array([0.2,0.4,0.6])
>>> mx.nd.random.negative_binomial(k, p, shape=2)
[[ 3.  2.]
[ 4.  4.]
[ 0.  5.]]
<NDArray 3x2 @cpu(0)>