View source: R/Kolmogorov_dist.R
Kolmogorov_dist | R Documentation |
To calculate the one-sample Kolmogorov distance between observations and a distribution.
Kolmogorov_dist(x, null, alternative = c("two.sided", "less", "greater"), ...)
x |
numeric vector, observations |
null |
cumulative distribution function |
alternative |
character scalar,
alternative hypothesis, either |
... |
additional arguments of |
Function Kolmogorov_dist()
is different from ks.test in the
following aspects
Ties in observations are supported.
The step function of empirical distribution is inspired by ecdf.
This is superior than (0:(n - 1))/n
in ks.test.
Discrete distribution (with discrete observation) is supported.
Discrete distribution (with continuous observation) is not supported yet. This will be an easy modification in future.
Only the one-sample Kolmogorov distance, not the one-sample Kolmogorov test, is returned, to speed up the calculation.
Function Kolmogorov_dist()
returns a numeric scalar.
# from ?stats::ks.test
x1 = rnorm(50)
ks.test(x1+2, y = pgamma, shape = 3, rate = 2)
Kolmogorov_dist(x1+2, null = pgamma, shape = 3, rate = 2) # exactly the same
# discrete distribution
x2 <- rnbinom(n = 1e2L, size = 500, prob = .4)
suppressWarnings(ks.test(x2, y = pnbinom, size = 500, prob = .4)) # warning on ties
Kolmogorov_dist(x2, null = pnbinom, size = 500, prob = .4) # wont be the same
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.