Continuous Random Variables
A continuous random variable is a probability distribution when the random variable X can have any value. The mean is defined by the location (loc) keyword. The standard deviation is determined by the scale (scale) keyword.
As we discussed that using the rv_continuous class we can create distributed subclasses and instances so there is a method called ‘norm’ which inherits from rv_continuous and this function will calculate the CDF for us.
Let X be a continuous random variable with PDF( (f) and CDF (F).
PDF – Probability Density Function
The PDF of a continuous random variable x satisfies the following conditions. If f\left ( x \right )\geq 0 for all x\in \mathbb{R} here f is piecewise continuous.
The CDF is found by integrating the PDF:
The pdf can be found by differentiating the CDF:
Python3
# Importing the numpy module for numpy array import numpy as npy # Importing the scipy.stats.norm from scipy.stats import norm # calculating the cdf for the numpy array print (norm.cdf(npy.array([ - 2 , 0 , 2 ]))) |
Output:
[0.02275013 0.5 0.97724987]
SciPy – Stats
The scipy.stats is the SciPy sub-package. It is mainly used for probabilistic distributions and statistical operations. There is a wide range of probability functions.
There are three classes:
Class | Description |
rv_continuous | For continuous random variables, we can create specialized distribution subclasses and instances. |
rv_discrete | For discrete random variables, we can create specialized distribution subclasses and instances. |
rv_histogram | generate specific distribution histograms. |
Contact Us