.. _kolmogorov_smirnov_test: Kolmogorov-Smirnov fitting test ------------------------------- This method deals with the modelling of a probability distribution of a random vector :math:`\vect{X} = \left( X^1,\ldots,X^{n_X} \right)`. It seeks to verify the compatibility between a sample of data :math:`\left\{ \vect{x}_1,\vect{x}_2,\ldots,\vect{x}_N \right\}` and a candidate probability distribution previously chosen. The Kolmogorov-Smirnov Goodness-of-Fit test allows one to answer this question in the one dimensional case :math:`n_X =1`, and with a continuous distribution. Let us limit the case to :math:`n_X = 1`. Thus we denote :math:`\vect{X} = X^1 = X`. This goodness-of-fit test is based on the maximum distance between the cumulative distribution function :math:`\widehat{F}_N` of the sample :math:`\left\{ x_1,x_2,\ldots,x_N \right\}` and that of the candidate distribution, denoted *F*. This distance may be expressed as follows: .. math:: D = \sup_x \left|\widehat{F}_N\left(x\right) - F\left(x\right)\right| With a sample :math:`\left\{ x_1,x_2,\ldots,x_N \right\}`, the distance is estimated by: .. math:: \widehat{D}_N = \sup_{i=1 \ldots N}\left|F\left(x_i\right)-\frac{i-1}{N} ; \frac{i}{N}-F\left(x_i\right)\right| Assume that the sample is drawn from the candidate distribution. By definition, the *p*-value of the test is the probability: .. math:: p = P(D > \widehat{D}_N) In the case where the fit is good, the value of :math:`\widehat{D}_N` is small, which leads to a p-value closer to 1. The candidate distribution will not be rejected if and only if :math:`p` is larger than a given threshold probability. In general, the threshold p-value is chosen to be 0.05: .. math:: p_{ref} = 0.05 Based on the p-value, - if :math:`p