scoringrules.owcrps_ensemble#
- scoringrules.owcrps_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 outcome-weighted CRPS (owCRPS) for a finite ensemble.
Computation is performed using the ensemble representation of the owCRPS in [1].
\[\begin{split}\begin{aligned} \mathrm{owCRPS}(F_{ens}, y) &= \frac{1}{M \bar{w}} \sum_{m = 1}^{M} |x_{m} - y|\,w(x_{m})\,w(y)\\ &\quad - \frac{1}{2 M^{2} \bar{w}^{2}} \sum_{m = 1}^{M} \sum_{j = 1}^{M} |x_{m} - x_{j}|\, w(x_{m})\,w(x_{j})\,w(y). \end{aligned}\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\) is the average weight.
- 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
numbaif available, elsenumpy.
- Returns:
- owcrpsarray_like
The owCRPS 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.owcrps_ensemble(obs, fct, w_func=w_func) array([0.91103733, 0.45212402, 0.35686667])