Random Rayleigh Distribution In NumPy
In this article, we will explore NumPy random rayleigh distribution, and demonstrate how to produce random numbers from this distribution through the numpy module.
What is Rayleigh Distribution?
The Rayleigh distribution is a continuous probability distribution used to model the magnitude of the vector sum of independent Gaussian random variables.
The PDF of the Rayleigh distribution is given by:
f(x; σ) = x/σ^2 * e^(-x^2/(2*σ^2))
where x is the random variable, σ is the scale parameter, and e is the base of the natural logarithm.
The mean and variance of the Rayleigh distribution are given by:
mean = σ*sqrt(π/2) variance = (4-π)/2 * σ^2
Numpy Random Rayleigh Distribution
The numpy random rayleigh function is used to generate random numbers from a Rayleigh distribution.
According to Numpy random Rayleigh, rayleigh distributions are applied to signal analysis.
Syntax
numpy.random.rayleigh(scale=1.0, size=None)
There are two parameters associated with it:
Parameters | Overview |
scale | (standard deviation) determines how smooth the distribution will be (by default, 1.0). |
size | Indicates the array’s shape. |
Take a random sample of 4.5 with a size of 1 by 5 for rayleigh distribution:
Example: 
Create a sample for the rayleigh distribution with scale one and size two and one:
Example: 
Visualization
Represent Rayleigh Distribution as follows:
Example: 
Display Rayleigh Distribution also with histogram:
Example: 
Similarity Between Rayleigh and Chi Square Distribution
Numpy random rayleigh is useful in many cases, Some of them are included below:
Wireless Communications
The Rayleigh distribution is used in wireless communications to model the magnitude of the received signal.
It can be used to generate random channel gains for simulations.
Engineering
The Rayleigh distribution is used in engineering to model the strength of materials.
It can be used to generate random material strengths for simulations.
Physics
The Rayleigh distribution is used in physics to model the magnitude of the displacement of a particle from its equilibrium position due to random forces.
Numpy random rayleigh can be used to generate random displacements for simulations.