scipy.stats.energy_distance
Distance between two probability distributions. Suppose two distributions u and v and their CDF are U and V, two random variables X and Y are there, then the energy distance will be the square root of:
D2(U,V) = 2E || X – Y || – E || X – X’ || – E || Y – Y’ || > 0,
- || denotes the length of a vector
Compute the energy distance between two 1D distributions.
Python3
# importing the stats module from scipy import stats as st # calling the function print (st.energy_distance([ 5 , 10 ], [ 10 , 20 ],\ [ 20 , 30 ], [ 30 , 40 ])) |
Output:
2.851422845685634
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