Table of Contents
ToggleThe Pareto Distribution is a continuous probability distribution used to model the distribution of wealth, income, or other resources, where a small portion of the population controls a large proportion of the total.
It is defined by two parameters: the shape parameter α and the scale parameter xm. The distribution is known for its “80/20 rule,” where roughly 80% of the effects come from 20% of the causes.
Example: The Pareto distribution can model the distribution of wealth in a population, where a few individuals hold most of the wealth.
The probability density function (PDF) of the Pareto distribution is −
f(x; α, xm) = (α * xmα) / xα+1, for x ≥ xm
Where,
The Pareto distribution is commonly used in the modeling of “rich-get-richer” phenomena, where the probability of a value decreases rapidly as the value increases.
NumPy provides a built-in function numpy.random.pareto() to generate random samples from the Pareto distribution. You need to specify the shape parameter α and scale parameter xm. The function will generate random values according to the Pareto distribution.
In this example, we generate 10 random samples from the Pareto distribution with a shape parameter (α) of 2 and a scale parameter (xm) of 1. Since the Pareto distribution is defined for values greater than or equal to xm, we add 1 to shift the distribution to start at 1 −
# Open Compiler
import numpy as np
# Generate 10 random samples from a Pareto distribution with shape parameter α=2 and scale parameter xm=1
samples = np.random.pareto(a=2, size=10) + 1 # xm=1, we add 1 to shift the distribution
print("Random samples from Pareto distribution:", samples)
Output:
Following is the output obtained −
Random samples from Pareto distribution: [11.21752644 1.19133192 1.13107575 1.00672706 1.77411845 1.29541783 5.99272696 1.62119397 1.08409404 1.25025651]
Visualization is an important tool to understand the characteristics of distributions. We can visualize the Pareto distribution by creating histograms using Matplotlib.
In the following example, we are first generating 1000 random samples from a Pareto distribution. We are then creating a histogram of the samples to visualize this distribution −
import numpy as np
import matplotlib.pyplot as plt
# Generate 1000 random samples from a Pareto distribution
samples = np.random.pareto(a=2, size=1000) + 1
# Plot the histogram of the samples
plt.hist(samples, bins=30, density=True, edgecolor='black')
plt.title('Pareto Distribution')
plt.xlabel('Value')
plt.ylabel('Probability Density')
plt.grid(True)
plt.show()
Output:
The histogram shows the probability density of the generated values. As expected, the distribution has a “heavy tail,” meaning that a small number of larger values contribute significantly to the total probability. The distribution decays quickly as the values increase −
Pareto Distribution
The two parameters of the Pareto distribution, α and xm, play an important role in shaping the distribution. Let us break down how each parameter affects the distribution −
The Pareto distribution has many practical applications in modeling and data analysis −
Like other distributions, the Pareto distribution has some interesting statistical properties −
You can modify the shape and scale parameters to generate Pareto distributions that better reflect your data.
Following is an example where we set α=3 and xm=2 to generate a Pareto distribution −
import numpy as np
import matplotlib.pyplot as plt
# Generate 1000 random samples with α=3 and xm=2
samples = np.random.pareto(a=3, size=1000) + 2
# Plot the histogram of the samples
plt.hist(samples, bins=30, density=True, edgecolor='black')
plt.title('Pareto Distribution with α=3 and xm=2')
plt.xlabel('Value')
plt.ylabel('Probability Density')
plt.grid(True)
plt.show()
Output:
This graph will show a distribution with a slightly less heavy tail than the one with α=2 and xm=1 −
Customized Pareto Distribution
For reproducibility, it is important to set a random seed. This ensures that every time you run the code, you get the same set of random numbers.
By setting the seed, you ensure that the random generation produces the same result every time the code is executed as shown in the example below −
# Open Compiler
import numpy as np
# Set the seed for reproducibility
np.random.seed(42)
# Generate 10 random samples with α=2 and xm=1
samples = np.random.pareto(a=2, size=10) + 1
print("Random samples from Pareto distribution with seed:", samples)
Output:
The result produced is as follows −
Random samples from Pareto distribution with seed: [1.26444595 4.50442711 1.93164669 1.57849408 1.08851288 1.08849733 1.03037147 2.73358909 1.58334718 1.85081305]
Key Takeaway: Master Pareto distributions with NumPy at Vista Academy!
