Skip to main content

Introduction to Python Rayleigh Distribution

Python Rayleigh Distribution

The Rayleigh distribution is characterized by a single parameter called the scale parameter (σ), which determines the spread or width of the distribution.

The probability density function (PDF) of the Rayleigh distribution is given by:

f(x) = (x / σ^2) * e^(-x^2 / (2 * σ^2))

Where x is the random variable.

In Python, you can work with the Rayleigh distribution using the numpy.random.rayleigh() function from the NumPy library. This function allows you to generate random numbers from a Rayleigh distribution.

As an example:

import numpy as np

# Define the scale parameter
scale = 2.5

# Generate random numbers from a Rayleigh distribution
size = 1000
random_numbers = np.random.rayleigh(scale, size=size)

In this example:

  • np.random.rayleigh(scale, size=size) generates an array of 1000 random numbers from a Rayleigh distribution with a scale parameter of 2.5.
  • The resulting array random_numbers will contain the generated random numbers.

The Rayleigh distribution is often used to model the amplitude of a random variable when the underlying components have equal variance and are normally distributed. It has applications in signal processing, wireless communication, and reliability analysis.