scoringrules.vrcrps_ensemble

scoringrules.vrcrps_ensemble#

scoringrules.vrcrps_ensemble(obs: ArrayLike, fct: Array, a: float = -inf, b: float = inf, m_axis: int = -1, *, ens_w: Array = None, w_func: Callable[[ArrayLike], ArrayLike] = None, backend: Backend = None) Array#

Estimate the vertically re-scaled CRPS (vrCRPS) for a finite ensemble.

Computation is performed using the ensemble representation of the vrCRPS in [1].

\[\begin{split}\begin{split} \mathrm{vrCRPS}(F_{ens}, y) = & \frac{1}{M} \sum_{m = 1}^{M} |x_{m} - y|w(x_{m})w(y) - \frac{1}{2 M^{2}} \sum_{m = 1}^{M} \sum_{j = 1}^{M} |x_{m} - x_{j}|w(x_{m})w(x_{j}) \\ & + \left( \frac{1}{M} \sum_{m = 1}^{M} |x_{m}| w(x_{m}) - |y| w(y) \right) \left( \frac{1}{M} \sum_{m = 1}^{M} w(x_{m}) - w(y) \right), \end{split}\end{split}\]

where \(F_{ens}(x) = \sum_{m=1}^{M} 1 \{ x_{m} \leq x \}/M\) is the empirical distribution function associated with an ensemble forecast \(x_{1}, \dots, x_{M}\) with \(M\) members, \(w\) is the chosen weight function, and \(\bar{w} = \sum_{m=1}^{M}w(x_{m})/M\).

Parameters:
obsarray_like

The observed values.

fctarray_like

The predicted forecast ensemble, where the ensemble dimension is by default represented by the last axis.

afloat

The lower bound to be used in the default weight function that restricts attention to values in the range [a, b].

bfloat

The upper bound to be used in the default weight function that restricts attention to values in the range [a, b].

m_axisint

The axis corresponding to the ensemble. Default is the last axis.

ens_warray, shape (…, m)

Weights assigned to the ensemble members. Array with the same shape as fct. Default is equal weighting. Weights are normalised so that they sum to one across the ensemble members.

w_funccallable, array_like -> array_like

Weight function used to emphasise particular outcomes.

backendstr, optional

The name of the backend used for computations. Defaults to numba if available, else numpy.

Returns:
vrcrpsarray_like

The vrCRPS between the forecast ensemble and obs for the chosen weight function.

Notes

Weighted scoring rules

Some theoretical background on weighted versions of scoring rules.

References

[1]

Allen, S., Ginsbourger, D., & Ziegel, J. (2023). Evaluating forecasts for high-impact events using transformed kernel scores. SIAM/ASA Journal on Uncertainty Quantification, 11(3), 906-940. Available at https://arxiv.org/abs/2202.12732.

Examples

>>> import numpy as np
>>> import scoringrules as sr
>>> rng = np.random.default_rng(123)
...
>>> def w_func(x):
...    return (x > -1).astype(float)
...
>>> obs = rng.normal(size=3)
>>> fct = rng.normal(size=(3, 10))
>>> sr.vrcrps_ensemble(obs, fct, w_func)
array([0.90036433, 0.41515255, 0.41653833])