5

I am looking for a library in C/C++ or java (or easily callable from those) that implements statistical normality tests: http://en.wikipedia.org/wiki/Normality_test

I had a quick look at boost and GSL, but they don't seem to include these.

I would appreciate links and examples how to use these tests (e.g. I am not sure how to link R libraries)

I would preferably work under Linux, but this is a secondary requirement.

Puppy
  • 144,682
  • 38
  • 256
  • 465
Grzenio
  • 35,875
  • 47
  • 158
  • 240

1 Answers1

3

See the Kolmogorov-Smirnov test. It's pretty simple -- you sort your data to get an array containing the population CDF, and compute the ideal CDF for a normal distribution with the population mean + standard deviation. Then iterate over the array and calculate the maximum deviation between the population CDF and the ideal CDF. Then plug it into the K-S distribution for a given degree of confidence.

All but the last part is trivial to implement in either language -- in Java here's one class to do that from Apache Commons.

See my answer to Benford's Law in Java - how to make a math function into Java for more details (different distribution, same idea though).

Community
  • 1
  • 1
Jason S
  • 184,598
  • 164
  • 608
  • 970
  • I downloaded http://commons.apache.org/math/download_math.cgi, but the class KolmogorovSmirnovDistributionImpl seems not to be there :(. Which jars do I need to include? – Grzenio Jan 02 '12 at 16:34
  • Drat, it looks like it's in commons-math 3.0, which hasn't had an official release yet. >:( Dunno why they make their javadoc available before the .jar file. Anyway the source is here: http://commons.apache.org/math/apidocs/src-html/org/apache/commons/math/distribution/KolmogorovSmirnovDistributionImpl.html – Jason S Jan 02 '12 at 16:42
  • [Latest link](https://commons.apache.org/proper/commons-math/apidocs/src-html/org/apache/commons/math3/stat/inference/KolmogorovSmirnovTest.html) – bishop Jul 15 '15 at 14:52