The KS test is used to determine if given values follow a specific distribution.
The function takes the values to be tested and the cumulative distribution function (CDF) as two parameters.
A CDF can be either a string representing a predefined distribution or a callable function that returns the probability. |
It can be used as either a one-tailed or two-tailed test.
By default, it is a two-tailed test. We can specify the alternative
parameter as a string, with options “two-sided,” “less,” or “greater.”
Determine if the given value follows a normal distribution.
import numpy as np from scipy.stats import kstest v = np.random.normal(size=100) res = kstest(v, ‘norm’) print(res) |
KstestResult(statistic=0.047798701221956841, pvalue=0.97630967161777515) |
To get a summary of values in an array, we can use the describe()
function.
It returns the following statistics:
nobs
)minmax
)Display the statistical summary of the values in an array.
import numpy as np from scipy.stats import describe v = np.random.normal(size=100) res = describe(v) print(res) |
DescribeResult( nobs=100, minmax=(-2.0991855456740121, 2.1304142707414964), mean=0.11503747689121079, variance=0.99418092655064605, skewness=0.013953400984243667, kurtosis=-0.671060517912661 ) |