scoringrules.crps_ensemble#
- scoringrules.crps_ensemble(obs: ArrayLike, fct: Array, m_axis: int = -1, *, ens_w: Array = None, estimator: str = 'qd', sorted_ensemble: bool = False, backend: Backend = None) Array#
Estimate the Continuous Ranked Probability Score (CRPS) for a finite ensemble.
For a forecast \(F\) and observation \(y\), the CRPS is formally defined as:
\[\begin{split}\mathrm{CRPS}(F, y) &= \int_{-\infty}^{\infty} (F(x) - \mathbf{1}\{y \le x\})^{2} dx \\ &= \mathbb{E} | X - y | - \frac{1}{2} \mathbb{E} | X - X^{\prime} |,\end{split}\]where \(X, X^{\prime} \sim F\) are independent. When \(F\) is the empirical distribution function of an ensemble forecast \(x_{1}, \dots, x_{M}\), the CRPS can be estimated in several ways. Currently, scoringrules supports several alternatives for
estimator:the energy estimator (
"nrg"),the fair estimator (
"fair"),the probability weighted moment estimator (
"pwm"),the approximate kernel representation estimator (
"akr").the AKR with circular permutation estimator (
"akr_circperm").the integral estimator (
"int").the quantile decomposition estimator (
"qd").
- Parameters:
- obsarray_like
The observed values.
- fctarray_like, shape (…, m)
The predicted forecast ensemble, where the ensemble dimension is by default represented by the last axis.
- 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.
- estimatorstr
Indicates the CRPS estimator to be used.
- sorted_ensemblebool
Boolean indicating whether the ensemble members are already in ascending order. Default is False.
- backendstr, optional
The name of the backend used for computations. Defaults to
numbaif available, elsenumpy.
- Returns:
- crpsarray_like
The CRPS between the forecast ensemble and obs.
See also
twcrps_ensemble,owcrps_ensemble,vrcrps_ensembleWeighted variants of the CRPS.
crps_quantileCRPS for quantile forecasts.
es_ensembleThe multivariate equivalent of the CRPS.
Notes
- Ensemble forecasts
Information on the different estimators available for the CRPS.
References
[1]Matheson JE, Winkler RL (1976). “Scoring rules for continuous probability distributions.” Management Science, 22(10), 1087-1096. doi:10.1287/mnsc.22.10.1087.
[2]Gneiting T, Raftery AE (2007). “Strictly proper scoring rules, prediction, and estimation.” Journal of the American Statistical Association, 102(477), 359-378. doi:10.1198/016214506000001437.
Examples
>>> import numpy as np >>> import scoringrules as sr >>> rng = np.random.default_rng(123) >>> obs = rng.normal(size=3) >>> pred = rng.normal(size=(3, 10)) >>> sr.crps_ensemble(obs, pred) array([0.69605316, 0.32865417, 0.39048665])