Conducting a Kolmogorov-Smirnov test

The Kolmogorov-Smirnov test (or simply KS test) is a test of equality for one-dimensional probability distributions that are continuous in nature. It is one of the popular methods to determine whether two sets of data points differ significantly.

How to do it...

  1. Create a method that takes two different data distributions. We will see if the difference of the two data distributions is significant by using Kolmogorov-Smirnov test:
            public void calculateKs(double[] x, double[] y){ 
    
  2. One of the key statistics in the test is d-statistic. It is a double value that we will need in order to calculate the p-value of the test:
            double d = TestUtils.kolmogorovSmirnovStatistic(x, y); 
    
  3. To evaluate the null hypothesis that the ...

Get Java Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.