KolmogorovSmirnovDist.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // SPDX-License-Identifier: GPL-3.0
  2. #ifndef KOLMOGOROVSMIRNOVDIST_H
  3. #define KOLMOGOROVSMIRNOVDIST_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /********************************************************************
  8. *
  9. * File: KolmogorovSmirnovDist.h
  10. * Environment: ISO C99 or ANSI C89
  11. * Author: Richard Simard
  12. * Organization: DIRO, Université de Montréal
  13. * Date: 1 February 2012
  14. * Version 1.1
  15. *
  16. * Copyright March 2010 by Université de Montréal,
  17. Richard Simard and Pierre L'Ecuyer
  18. =====================================================================
  19. This program is free software: you can redistribute it and/or modify
  20. it under the terms of the GNU General Public License as published by
  21. the Free Software Foundation, version 3 of the License.
  22. This program is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. GNU General Public License for more details.
  26. You should have received a copy of the GNU General Public License
  27. along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. =====================================================================*/
  29. /*
  30. *
  31. * The Kolmogorov-Smirnov test statistic D_n is defined by
  32. *
  33. * D_n = sup_x |F(x) - S_n(x)|
  34. *
  35. * where n is the sample size, F(x) is a completely specified theoretical
  36. * distribution, and S_n(x) is an empirical distribution function.
  37. *
  38. *
  39. * The function
  40. *
  41. * double KScdf (int n, double x);
  42. *
  43. * computes the cumulative probability P[D_n <= x] of the 2-sided 1-sample
  44. * Kolmogorov-Smirnov distribution with sample size n at x.
  45. * It returns at least 13 decimal digits of precision for n <= 500,
  46. * at least 7 decimal digits of precision for 500 < n <= 100000,
  47. * and a few correct decimal digits for n > 100000.
  48. *
  49. */
  50. double KScdf (int n, double x);
  51. /*
  52. * The function
  53. *
  54. * double KSfbar (int n, double x);
  55. *
  56. * computes the complementary cumulative probability P[D_n >= x] of the
  57. * 2-sided 1-sample Kolmogorov-Smirnov distribution with sample size n at x.
  58. * It returns at least 10 decimal digits of precision for n <= 500,
  59. * at least 6 decimal digits of precision for 500 < n <= 200000,
  60. * and a few correct decimal digits for n > 200000.
  61. *
  62. */
  63. double KSfbar (int n, double x);
  64. /*
  65. * NOTE:
  66. * The ISO C99 function log1p of the standard math library does not exist in
  67. * ANSI C89. Here, it is programmed explicitly in KolmogorovSmirnovDist.c.
  68. * For ANSI C89 compilers, change the preprocessor condition to make it
  69. * available.
  70. */
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif