Cramér–von-Mises criterion

In statistics the Cramér-von-Mises criterion is a criterion used for judging the goodness of fit of a probability distribution $$F^*$$ compared to a given empirical distribution function $$F_n$$, or for comparing two empirical distributions. It is also used as a part of other algorithms, such as minimum distance estimation. It is defined as


 * $$\omega^2 = \int_{-\infty}^{\infty} [F_n(x)-F^*(x)]^2\,\mathrm{d}F^*(x)$$

In one-sample applications $$F^*$$ is the theoretical distribution and $$F_n$$ 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.

The Cramér-von-Mises test is an alternative to the Kolmogorov-Smirnov test.

Cramér-von-Mises test (one sample)
Let $$x_1,x_2,\cdots,x_n$$ be the observed values, in increasing order. Anderson showed that


 * $$T = n \omega^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. Anderson shows that


 * $$T = N \omega^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)^2 + M \sum_{j=1}^M (s_j-j)^2 $$

If the value of T is larger than the tabulated values 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).

The above assumes there are no duplicates in the $$x$$, $$y$$, and $$r$$ sequences. So $$x_i$$ is unique, and its rank is $$i$$ in the sorted list $$x_1,...x_N$$. If there are duplicates, and $$x_i$$ through $$x_j$$ are a run of identical values in the sorted list, then one common approach is the midrank method: assign each duplicate a "rank" of $$(i+j)/2$$. In the above equations, in the expressions $$(r_i-i)^2$$ and $$(s_j-j)^2$$, duplicates can modify all four variables $$r_i$$,  $$i$$,   $$s_j$$,  and $$j$$.