Cramér-von-Mises criterion

In statistics the Cramér-von-Mises criterion for judging the goodness of fit of a probability distribution $$F^*$$ compared to a given distribution $$F$$ is given by


 * $$W^2 = \int_{-\infty}^\infty [F(x)-F^*(x)]^2 dF(x) $$

In one-sample applications $$F$$ is the theoretical distribution and $$F^*$$ is the empirically observed distribution. Alternatively the two distributions can both be empirically estimated ones; this is called the two-sample case.

The criterion is named after Harald Cramér and Richard Edler von Mises who first proposed it in 1928-1930. The generalization to two samples is due to Anderson (1962).

The Cramér-von-Mises test is an alternative to the Kolmogorov-Smirnov test. It is thought that the CvM test is more powerful than the KS test, but this has not been shown theoretically.

Cramér-von-Mises test (one sample)
Let $$x_1,x_2,\cdots,x_n$$ be the observed values, in increasing order. Then it is possible to show that


 * $$T = n W^2 = \frac{1}{12n} + \sum_{i=1}^n \left[ \frac{2i-1}{2n}-F(x_i) \right]^2. $$

If this value is larger than the tabulated value we can reject the hypothesis that the data come from the distribution $$F(.)$$.

Cramér-von-Mises test (two samples)
Let $$x_1,x_2,\cdots,x_n$$ and $$y_1,y_2,\cdots,y_m$$ be the observed values in the first and second sample respectively, in increasing order. Let $$r_1,r_2,\cdots,r_n$$ be the ranks of the x's in the combined sample, and let $$s_1,s_2,\cdots,s_m$$ be the ranks of the y's in the combined sample. It can be shown that


 * $$T = n W^2 = \frac{U}{n m (n+m)}-\frac{4 m n - 1}{6(m+n)} $$

where U is defined as


 * $$U = n \sum_{i=1}^n (r_i-i) + m \sum_{j=1}^m (s_j-j) $$

If the value of T is larger than the tabulated value we can reject the hypothesis that the two samples come from the same distribution. (Some books give critical values for U, which is more convenient, as it avoids the need to compute T via the expression above. The conclusion will be the same).