# Cramervonmises

> Compute the cramervonmises metric — provided by scipy.stats. Use when the user has predictions and ground-truth and needs to compute cramervonmises, or asks how to score with cramervonmises.

- Skill: `qhjqhj00/cramervonmises` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/cramervonmises`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/cramervonmises/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/cramervonmises

---


# cramervonmises

> Metric `cramervonmises` from `scipy.stats` (scipy.stats.cramervonmises)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with cramervonmises, or
mentions `scipy.stats.cramervonmises` directly, or wants the standard scipy.stats implementation.

## Reference signature

```python
from scipy.stats import cramervonmises

# cramervonmises(rvs, cdf, args=(), *, axis=0, nan_policy='propagate', keepdims=False)
```

## Library docstring

```
Perform the one-sample Cramér-von Mises test for goodness of fit.

This performs a test of the goodness of fit of a cumulative distribution
function (cdf) :math:`F` compared to the empirical distribution function
:math:`F_n` of observed random variates :math:`X_1, ..., X_n` that are
assumed to be independent and identically distributed ([1]_).
The null hypothesis is that the :math:`X_i` have cumulative distribution
:math:`F`.

The test statistic :math:`T` is defined as in [1]_, where :math:`\omega^2`
is the Cramér-von Mises criterion and :math:`x_i` are the observed values.

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

Parameters
----------
rvs : array_like
    A 1-D array of observed values of the random variables :math:`X_i`.
    The sample must contain at least two observations.
cdf : str or callable
    The cumulative distribution function :math:`F` to test the
    observations against. If a string, it should be the name of a
    distribution in `scipy.stats`. If a callable, that callable is used
    to calculate the cdf: ``cdf(x, *args) -> float``.
args : tuple, optional
    Distribution parameters. These are assumed to be known; see Notes.
axis : int or None, default: 0
    If an int, the axis of the input along which to compute the statistic.
    The statistic of each axis-slice (e.g. row) of the input will appear in a
    corresponding element of the output.
    If ``None``, the input will be raveled before computing the statistic.
nan_policy : {'propagate', 'omit', 'raise'}
    Defines how to handle input NaNs.

    - ``propagate``: if a NaN is present in the axis slice (e.g. row) along
      which the  statistic is computed, the corresponding entry of the output
      will be NaN.
    - ``omit``: NaNs will be omitted when performing the calculation.
      If insufficient data remains in the axis slice along which the
      statistic is computed, the corresponding entry of the output will be
      NaN.
    - ``raise``: if a NaN is present, a ``ValueError`` will be raised.
keepdims : bool, default: False
    If this is set to True, the axes which are reduced are left
    in the result as dimens
```

## Quick recipe

```python
import scipy.stats as _m
score = _m.cramervonmises(y_true, y_pred)
```

## Don'ts

- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.

