0

Below is the python code for the KS test.

import numpy as np
from scipy import stats

test = np.random.normal(23,10,50) test_std = (test-23)/10 stat1,p1 = stats.kstest(test,'norm') stat2,p2 = stats.kstest(test_std,'norm') print(p1) print(p2)

OUTPUT

2.5353101018046572e-70
0.9887775065294439

I took a normal distribution mean = 23 and std=10 and compared with normal distribution using KS test then the result is the distributions are not similar but when I standardize the same normal distribution I got the result that the distribution are similar but as KS test works on difference in cdf which will not get affected by the standardization why am I getting different results.

  • 2
    The documentation should tell you what hypothesis the test is of. At a guess, your test in each case compares with a normal distribution of mean 0 and SD 1. One test is fair because the data have been standardized, but the other isn't. – Nick Cox Mar 14 '22 at 07:22
  • 1
    You shouldn't normalize data before applying the KS test. See this thread for a recent explanation: https://stats.stackexchange.com/questions/564912/is-it-reasonable-to-use-the-kolmogorov-smirnov-test-to-assess-the-normality-of-a – num_39 Mar 14 '22 at 07:32

0 Answers0