In statistics, the Kolmogorov–Smirnov test (K–S test or KS test) is a nonparametric test of the equality of continuous, one-dimensional probability distributions that can be used to compare a sample with a reference probability distribution (one-sample K–S test), or to compare two samples (two-sample K–S test)
Questions tagged [kolmogorov-smirnov]
123 questions
25
votes
2 answers
Kolmogorov-Smirnov test in R
I tried to use the Kolmogorov-Smirnov test to test normality of a sample. This is a small simple example of what I do:
x <- rnorm(1e5, 1, 2)
ks.test(x, "pnorm")
Here is the result R gives me:
One-sample Kolmogorov-Smirnov test
data: x
D =…

gagaouthu
- 299
- 1
- 3
- 9
9
votes
3 answers
How to calculate the Kolmogorov-Smirnov statistic between two weighted samples
Let's say that we have two samples data1 and data2 with their respective weights weight1 and weight2 and that we want to calculate the Kolmogorov-Smirnov statistic between the two weighted samples.
The way we do that in python follows:
import numpy…

Luca Jokull
- 181
- 2
- 9
8
votes
2 answers
Applying function (ks.test) between two data frames column-wise in R
My simple question is: How do you do a ks.test between two data frames column by column?
Eg. We have two data frames:
D1 <- data.frame(D$Ag, D$Al, D$As, D$Ba, D$Be, D$Ca, D$Cd, D$Co, D$Cu, D$Cr)
D2 <- data.frame(S$Ag, S$Al, S$As, S$Ba, S$Be, S$Ca,…

Ib Nemer
- 85
- 1
- 6
6
votes
1 answer
p_value is 0 when I use scipy.stats.kstest() for large dataset
I have a unique series with there frequencies and want to know if they are from normal distribution so I did a Kolmogorov–Smirnov test using scipy.stats.kstest. Since, to my knowledge, the function takes only a list so I transform the frequencies to…

Gabriel
- 161
- 2
- 11
5
votes
1 answer
How to perform KS.test in a dataframe in R by groups
I want to perform two-sample Kolmogorov-Smirnov (KS) tests in R for an example dataframe "data" below:
Protein1 Protein2 Protein3 Protein4 Protein5 Protein6 Protein7 Protein8 Group
Sample1 0.56 1.46 0.64 2.53 …

Letin
- 1,255
- 5
- 20
- 36
5
votes
1 answer
obtaining the critical values needed for the kolmogorov-smirnov test
I'm talking about retrieving the values of this table media a python formula
https://www.soest.hawaii.edu/GG/FACULTY/ITO/GG413/K_S_Table_one_Sample.pdf
i've been looking for a while but scipy functions do not look for this value and tbh I'm getting…

ayy_chemixd
- 113
- 10
5
votes
1 answer
Problems with ks.test and ties
I have a distribution, for example:
d
#[1] 4 22 15 5 9 5 11 15 21 14 14 23 6 9 17 2 7 10 4
Or, the vector d in dput format.
d <- c(4, 22, 15, 5, 9, 5, 11, 15, 21, 14, 14, 23, 6, 9, 17, 2, 7, 10, 4)
And when I apply the ks.test,:
gamma <-…

smi
- 73
- 1
- 1
- 8
5
votes
1 answer
Poorly implemented two-sample Kolmogorov-Smirnov test (kstest2) in Matlab?
Am I missing something obvious or Matlab's kstest2 is giving very poor p-values?
Under very poor I mean that I have the suspicion that it is even wrongly implemented.
Help page of kstest2 states that the function calculates asymptotic p-value,…

rozsasarpi
- 1,621
- 20
- 34
4
votes
1 answer
Very low p-values in Python Kolmogorov-Smirnov Goodness of Fit Test
I have a set of data and fit the corresponding histogram by a lognormal distribution.
I first calculate the optimal parameters for the lognormal function, and then plot the histogram and the lognormal function. This gives quite good results:
import…

Charles M.
- 83
- 1
- 4
4
votes
1 answer
Kolmogorov Smirnov Test in Spark (Python) not working?
I was doing a normality test in Python spark-ml and saw what I think is an bug.
Here is the setup, i have a data-set that is normalized (range -1, to 1).
When I do a histogram, i can clearly see that the data is NOT normal:
>>>…

Carlos Andres Castro
- 173
- 1
- 9
3
votes
1 answer
Kolmogorov-Smirnov Test in Python for Goodness of fit
I am trying to get the best distributions for my data. The fitting is finished as shown in below figure, but i need a measurement, to choose the best model. I compared goodness of fit with a chi-squared value, and test for significant difference…

Case Msee
- 405
- 5
- 17
3
votes
1 answer
Kolomogorov-Smirnov test: C to R translation issue
I am having difficulty translating an algorithm from C to R. It's about Kolmogorov Smirnov test, and more specifically the KS probability function
In 'Numerical Recipes in C', 'probks', it's coded as
#include
#define EPS1 0.001
#define…

mjs
- 150
- 1
- 20
3
votes
0 answers
How do you create a Kolmogorov-Smirnov chart in python for a 2 sample string lists?
I am having difficulty in creating a Kolmogorov-Smirnov chart for 2 sample string lists that will display Cumulative Distribution Function (CDF)?
As shown in Two-sample Kolmogorov–Smirnov test
I have been able to calculate the…

Polly
- 31
- 4
3
votes
4 answers
How to use a proper normalization to have the right p_values and ks_values from Kolmogorov-Smirnov test (KS test)?
I am working on a finance problem and I am to implement a function to use Kolmogorov-Smirnov test(KS test) between a normal distribution of each stock's signal returns. I am to run the KS test on a normal distribution against each stock's signal…

Eyong Kevin Enowanyo
- 846
- 10
- 15
3
votes
1 answer
Kolmogorov-Smirnov test for normality in MATLAB - data normalisation?
I'm using the Kolmogorov-Smirnov test in MATLAB to determine the normality of each column of a data matrix prior to performing generalised linear regression. An example data vector is:
data =…

Laura
- 89
- 8