Computes the complementary cdf
cont_ks_c_cdf(q, n)
numeric value between 0 and 1, at which the complementary cdf
the sample size
Numeric value corresponding to
Given a random sample n
with an empirical cdf
The function cont_ks_c_cdf
implements the FFT-based algorithm proposed by Moscovich and Nadler (2017) to compute the complementary cdf, ks.test
in the package stats and the function ks.test
in the package dgof.
More precisely, in these packages, the exact p-value, ks.test
is that the sample size should be less than 100, and the computation time is cont_ks_c_cdf
provides results with at least 10 correct digits after the decimal point for sample sizes n
> 100000, accurate results can still be computed with similar accuracy, but at a higher computation time.
See Dimitrova, Kaishev, Tan (2020), Appendix C for further details and examples.
Dimitrina S. Dimitrova, Vladimir K. Kaishev, Senren Tan. (2020) "Computing the Kolmogorov-Smirnov Distribution When the Underlying CDF is Purely Discrete, Mixed or Continuous". Journal of Statistical Software, 95(10): 1-42. doi:10.18637/jss.v095.i10.
Marsaglia G., Tsang WW., Wang J. (2003). "Evaluating Kolmogorov's Distribution". Journal of Statistical Software, 8(18), 1-4.
Moscovich A., Nadler B. (2017). "Fast Calculation of Boundary Crossing Probabilities for Poisson Processes". Statistics and Probability Letters, 123, 177-182.
# NOT RUN {
## Compute the value for P(D_{100} >= 0.05)
KSgeneral::cont_ks_c_cdf(0.05, 100)
## Compute P(D_{n} >= q)
## for n = 100, q = 1/500, 2/500, ..., 500/500
## and then plot the corresponding values against q
n <- 100
q <- 1:500/500
plot(q, sapply(q, function(x) KSgeneral::cont_ks_c_cdf(x, n)), type='l')
## Compute P(D_{n} >= q) for n = 141, nq^{2} = 2.1 as shown
## in Table 18 of Dimitrova, Kaishev, Tan (2020)
KSgeneral::cont_ks_c_cdf(sqrt(2.1/141), 141)
# }
Run the code above in your browser using DataLab