Kolmogorov-Smirnov Test

tags: #statistics/inferential/assumption_check

The Kolmogorov-Smirnov test is used to understand how well the distribution of sample data conforms to some theoretical distribution (i.e., whether the two are different from each other).

This is based on the maximum difference between the cumulative distribution functions (CDFs) of the two distributions being compared, such that:

H0:The two distributions are the same.HA:The two distributions are NOT the same.

Running in Python

from scipy.stats import kstest

# Perform the Kolmogorov-Smirnov test
statistic, pvalue = kstest(df["target"], 'norm') #second parameter to specify the theoretical distribution you want to compare it to

print(f"KS test statistic: {statistic:.3f}")
print(f"p-value: {pvalue:.3f}")
Powered by Forestry.md