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