# How can I calculate the power of Kolmogorov-Smirnov Test for a normal distribution?

I have a question about calculating the power of Kolmogorov-Smirnov test, given the following: H0: mu=0, H1:m!=0, alpha = 0.05, for N(mu, 1), while true mu=0.1, for sample sizes n1 = 30, n2 = 1000. I have been struggling to find a way to calculate the power of KS test. I have covered this thread, but it was covering the exponential distribution, and I am not really getting how to apply that to normal distribution.

Any suggestions? I would be also glad to receive recommendations if there are any resources/literature that would help with this.

• All the considerations mentioned in comments under the linked question carry over to the corresponding case with the normal. You have a specific alternative (rather than seeking an entire power curve). Aside from simulating from normals rather than exponentials (and similarly applying the specific details of parameters and sample size in your question), literally everything carries across. There's nothing else to do, every principle or idea is completely addressed. This is not the place to get people to merely make trivial replacements like substituting rnorm in place of rexp ... ctd Aug 6, 2021 at 16:40
• ... ctd (and replacing the arguments to rexp with the correct ones to rnorm) in mean(replicate(nsim, ks.test(rexp(n1,1),rexp(n2,s[i]))$p.value)<alpha) -- which is the line you need for a single alternative. That's just simple coding, not statistics ... and it sounds like we could end up just doing your homework or something. It would seem irresponsible to just post an answer. Aug 6, 2021 at 16:41 • The power equals$\alpha,$, because one can make the KS statistic come arbitrarily close to the null distribution by adding a tiny amount of contamination in the tails. The problem is that the question is under-specified: power depends on the detailed description of the alternate hypothesis. Yours is too general to be useful. – whuber Aug 6, 2021 at 16:51 ## 1 Answer Please take the tour of our site, clarify your notation, and show what you have tried. To the extent that I understand what you are trying to do, the following hint may be helpful. Hint: Below is one possibly relevant K-S test in R; it does not reject $$H_0: \mu=0$$ against $$H_1: \mu= 0.1$$ at the 5% level. ks.test(rnorm(10, 0, 1), rnorm(1000, .1, 1), alternative="gr") Two-sample Kolmogorov-Smirnov test data: rnorm(10, 0, 1) and rnorm(1000, 0.1, 1) D^+ = 0.122, p-value = 0.7447 alternative hypothesis: the CDF of x lies above that of y  Here are 100,000 possibly relevant K-S tests, among which 6.4% reject $$H_0: \mu=0$$ against $$H_1: \mu = 0.1$$ at the 5% level. pv= replicate(10^5, ks.test(rnorm(10, 0, 1), rnorm(1000, .1, 1), alternative="gr")$p.val)
mean(pv <= .05)
 0.06416

• why the one-sided test? Aug 6, 2021 at 16:44
• Question is unclear about alternative. Aug 6, 2021 at 16:46
• Right, well fair enough. Aug 6, 2021 at 16:48
• I agree OP may want power of two-sided test for specific alternative $\mu = 0.1,$ but not sure. Would like clarification. If two-sided test is intended, then remove parameter alternative="gr". In any case, power will not be good even with $n_2=1000$ because so little is known about Population 1 with only $n_1 = 10$ observations. Aug 6, 2021 at 17:01
• Thanks! I get the logic now, that helped a lot. And sorry for an unclear question, I'm new here, will definitely do better next time. Aug 16, 2021 at 5:57