# mxnet.ndarray.random.generalized_negative_binomial¶

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

Draw random samples from a generalized negative binomial distribution.

Samples are distributed according to a generalized negative binomial distribution parametrized by mu (mean) and alpha (dispersion). alpha is defined as 1/k where k is the failure limit of the number of unsuccessful experiments (generalized to real numbers). Samples will always be returned as a floating point data type.

Parameters
• mu (float or NDArray, optional) – Mean of the negative binomial distribution.

• alpha (float or NDArray, optional) – Alpha (dispersion) parameter of the negative binomial distribution.

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

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

Examples

>>> mx.nd.random.generalized_negative_binomial(10, 0.5)
[ 19.]
<NDArray 1 @cpu(0)>
>>> mx.nd.random.generalized_negative_binomial(10, 0.5, shape=(2,))
[ 30.  21.]
<NDArray 2 @cpu(0)>
>>> mu = mx.nd.array([1,2,3])
>>> alpha = mx.nd.array([0.2,0.4,0.6])
>>> mx.nd.random.generalized_negative_binomial(mu, alpha, shape=2)
[[ 4.  0.]
[ 3.  2.]
[ 6.  2.]]
<NDArray 3x2 @cpu(0)>