Result analysis
Above image observations –
A - P = 2 A - Q = 3 A - R = 0
Above image observations:
B - P = 1 B - Q = 0 B - R = 4
stats.describe()
This function basically calculates the several descriptive statistics of the argument array.
Syntax:
scipy.stats.describe(a, axis=0, ddof=1, bias=True, nan_policy=’propagate’)
where,
- Input array – array for which we want to generate the statistics.
- axis ( int , float ) { # optional } – Axis along which statistics are calculated. The default axis is 0.
- ddof ( int ) { # optional } – Delta Degrees for variance. Default ddof = 1.
- bias ( bool ) { # optional } – skewness and kurtosis calculations for statistical bias.
- nan_policy – { ‘propagate’,’raise’,’omit’ } { # optional ) – Handle the NAN inputs.
Return:
- nbos ( int or ndarray ) – length of data along axis value.
- minmax ( tuple of ndarrays or floats ) – Minimum and Maximum value of input array along the given axis.
- mean ( float or ndarray ) – mean of input array.
- variance ( ndarray or float ) – variance of input array along the given axis.
- skewness ( float or ndarray ) – skewness of input array along the given axis.
- kurtosis ( ndarray or float ) – kurtosis of input array along the given axis.
Python3
# importing the stats and numpy module from scipy import stats as st import numpy as npy # ID input array array = npy.array([ 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 ]) # calling the describe function print (st.describe(array)) |
Output:
DescribeResult( nobs=8, minmax=(10, 80), mean=45.0, variance=600.0, skewness=0.0, kurtosis=-1.2380952380952381)
Python3
# importing the stats and numpy module from scipy import stats as st import numpy as npy # 2D array nd = npy.array([[ 5 , 6 ], [ 2 , 3 ], [ 5 , 5 ],\ [ 7 , 9 ], [ 9 , 8 ], [ 8 , 7 ]]) # calling the describe function print (st.describe(nd)) |
Output:
DescribeResult(nobs=6, minmax=(array([2, 3]), array([9, 9])), mean=array([6. , 6.33333333]), variance=array([6.4 , 4.66666667]), skewness=array([-0.40594941, -0.3380617 ]), kurtosis=array([-0.9140625, -0.96 ]))
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