# networkx.utils.random_sequence.zipf_rv¶

zipf_rv(alpha, xmin=1, seed=None)[source]

Returns a random value chosen from the Zipf distribution.

The return value is an integer drawn from the probability distribution

$p(x)=\frac{x^{-\alpha}}{\zeta(\alpha, x_{\min})},$

where $$\zeta(\alpha, x_{\min})$$ is the Hurwitz zeta function.

Parameters
alphafloat

Exponent value of the distribution

xminint

Minimum value

seedinteger, random_state, or None (default)

Indicator of random number generation state. See Randomness.

Returns
xint

Random value from Zipf distribution

Raises
ValueError:

If xmin < 1 or If alpha <= 1

Notes

The rejection algorithm generates random values for a the power-law distribution in uniformly bounded expected time dependent on parameters. See [1] for details on its operation.

References

1

Luc Devroye, Non-Uniform Random Variate Generation, Springer-Verlag, New York, 1986.

Examples

>>> nx.utils.zipf_rv(alpha=2, xmin=3, seed=42)
8