random.paretovariate

Full name
random.paretovariate
Library
random
Syntax

random.paretovariate(alpha)

Description

The random.paretovariate function returns a random number drawn from a Pareto distribution .

Parameters
  • alpha: Parameter α of the Pareto distribution.
Result

The random.paretovariate function returns a real number.

Examples

We can generate a random number extracted from a Pareto distribution with α equal to 10 with the following code:

random.paretovariate(10)
1.023752633838368

To confirm the distribution from which the random numbers are extracted we can generate one hundred thousand random numbers from a Pareto distribution with α equal to 10 and show its histogram:

import matplotlib.pyplot as plt
plt.figure(figsize = (8, 4))
plt.hist([random.paretovariate(10) for i in range(100000)], bins = 100)
plt.grid()
plt.show()
random.paretovariate
Submitted by admin on Fri, 03/19/2021 - 14:46