The Rayleigh distribution is a continuous probability distribution used mainly in the field of physics and engineering. It's often used to model the magnitude of a 2D random vector whose coordinates are independent and identically distributed Gaussian random variables.
sympy.stats provides the Rayleigh class to represent and manipulate the Rayleigh distribution.
Here's a simple demonstration of the Rayleigh distribution in sympy.stats:
from sympy.stats import Rayleigh, density from sympy import Symbol, pprint sigma = Symbol("sigma", positive=True) # scale parameter z = Rayleigh("z", sigma) # Define a Rayleigh random variable density_z = density(z) pprint(density_z, use_unicode=True)
For instance, if you want to compute the value of the density function at a specific point x:
x = Symbol("x") density_val = density_z.doit().subs(x, 1) print(density_val) You can also compute the mean, variance, and other statistics:
from sympy.stats import E, variance mean = E(z) var = variance(z) print("Mean:", mean) print("Variance:", var) Remember that for the Rayleigh distribution:
Ensure you have SymPy installed to run the above code:
pip install sympy
You can then use the provided examples as a foundation to explore more functionalities related to the Rayleigh distribution in SymPy.
formats jquery-cookie prometheus-alertmanager exists quaternions ng-modal audio-recording rx-java zlib iot