scoringrules.twvs_ensemble

Contents

scoringrules.twvs_ensemble#

scoringrules.twvs_ensemble(obs: Array, fct: Array, v_func: Callable, w: Array = None, m_axis: int = -2, v_axis: int = -1, *, ens_w: Array = None, p: float = 0.5, estimator: str = 'nrg', backend: Backend = None) Array#

Compute the Threshold-Weighted Variogram Score (twVS) for a finite multivariate ensemble.

Computation is performed using the ensemble representation of the twVS in [1],

\[\mathrm{twVS}(F_{ens}, \mathbf{y}) = \sum_{i,j=1}^{D}(|v(\mathbf{y})_i - v(\mathbf{y})_{j}|^{p} - \frac{1}{M} \sum_{m=1}^{M}|v(\mathbf{x}_{m})_{i} - v(\mathbf{x}_{m})_{j}|^{p})^{2},\]

where \(F_{ens}\) is the ensemble forecast \(\mathbf{x}_{1}, \dots, \mathbf{x}_{M}\) with \(M\) members, and \(v\) is the chaining function used to target particular outcomes.

Parameters:
obsarray_like

The observed values, where the variables dimension is by default the last axis.

fctarray_like

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

warray_like

The weights assigned to pairs of dimensions. Must be of shape (…, D, D), where D is the dimension, so that the weights are in the last two axes.

v_funccallable, array_like -> array_like

Chaining function used to emphasise particular outcomes.

m_axisint

The axis corresponding to the ensemble dimension. Defaults to -2.

v_axisint

The axis corresponding to the variables dimension. Defaults to -1.

ens_warray_like

Weights assigned to the ensemble members. Array with one less dimension than fct (without the v_axis dimension). Default is equal weighting. Weights are normalised so that they sum to one across the ensemble members.

pfloat

The order of the Variogram Score. Typical values are 0.5, 1.0 or 2.0. Defaults to 0.5.

estimatorstr

The variogram score estimator to be used.

backendstr

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

Returns:
twvs_ensemblearray_like

The computed Threshold-Weighted Variogram Score.

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)
>>> obs = rng.normal(size=(3, 5))
>>> fct = rng.normal(size=(3, 10, 5))
>>> sr.twvs_ensemble(obs, fct, lambda x: np.maximum(x, -0.2))
array([5.94996894, 4.72029765, 6.08947229])