all Python 3randomfunction
random.paretovariate
distributions
A random number from the Pareto distribution with shape alpha; always ≥ 1.
Syntax
random.paretovariate(alpha)
This is a heavy-tailed distribution: the mean exists only when alpha > 1 and the variance only when alpha > 2, so for alpha near 1 the sample average jumps wildly between runs and tells you almost nothing. The scale is fixed at 1 (the minimum possible value) — multiply the result if you need a different lower bound. Pass a positive alpha; zero raises ZeroDivisionError.
Examples
import random
print(random.paretovariate(1.0) >= 1.0) # → True
print(random.paretovariate(1000.0) < 1.1) # → True
sample = [random.paretovariate(2.0) for _ in range(1000)]
print(min(sample) >= 1.0) # → True
print(random.paretovariate(0.0)) # → ZeroDivisionError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy