using Distributions
import HypothesisTests as HT
HT.pvalue(HT.ApproximateOneSampleKSTest(rand(Normal(), 1_000_000), Normal()))
I expected that the answer will be very close to one, but depending on the run it can be anywhere from 0.01 to 0.98. Why it is so? The same is with OneSampleADTest and other tests.
I donβt think anything is wrong: when the null hypothesis is true, the p-value is uniformly distributed. So you have in particular 1% chance of observing a p-value <= 0.01, and 2% of observing something >= 98%.
For example, repeating your experiment 10000 times (with a much smaller sample size to avoid long computations, but this doesnβt change the result):