scoringrules.vrvs_ensemble

Contents

scoringrules.vrvs_ensemble#

scoringrules.vrvs_ensemble(obs: Array, fct: Array, w_func: Callable, w: Array = None, m_axis: int = -2, v_axis: int = -1, *, ens_w: Array = None, p: float = 0.5, backend: Backend = None) Array#

Compute the Vertically Re-scaled Variogram Score (vrVS) for a finite multivariate ensemble.

Computation is performed using the ensemble representation of the vrVS in [Allen et al. (2022)](https://arxiv.org/abs/2202.12732):

\[\begin{split}\begin{split} \mathrm{vrVS}(F_{ens}, \mathbf{y}) = & \frac{1}{M} \sum_{m=1}^{M} \sum_{i,j=1}^{D}(|y_{i} - y_{j}|^{p} - |x_{m,i} - x_{m,j}|^{p})^{2} w(\mathbf{x}_{m}) w(\mathbf{y}) \\ & - \frac{1}{2 M^{2}} \sum_{k,m=1}^{M} \sum_{i,j=1}^{D} \left( |x_{k,i} - x_{k,j}|^{p} - |x_{m,i} - x_{m,j}|^{p} \right)^{2} w(\mathbf{x}_{k}) w(\mathbf{x}_{m})) \\ & + \left( \frac{1}{M} \sum_{m = 1}^{M} \sum_{i,j=1}^{D}(|x_{m,i} - x_{m,j}|^{p} w(\mathbf{x}_{m}) - \sum_{i,j=1}^{D}(|y_{i} - y_{j}|^{p} w(\mathbf{y}) \right) \left( \frac{1}{M} \sum_{m = 1}^{M} w(\mathbf{x}_{m}) - w(\mathbf{y}) \right), \end{split}\end{split}\]

where \(F_{ens}\) is the ensemble forecast \(\mathbf{x}_{1}, \dots, \mathbf{x}_{M}\) with \(M\) members, \(w\) is the chosen weight function, and \(\bar{w} = \sum_{m=1}^{M}w(\mathbf{x}_{m})/M\).

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.

w_funccallable, array_like -> array_like

Weight function used to emphasise particular outcomes.

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.

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.

backendstr

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

Returns:
vrvs_ensemblearray_like

The computed Vertically Re-scaled Variogram Score.

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.vrvs_ensemble(obs, fct, lambda x: x.max() + 1.0)
array([46.48256493, 57.90759816, 92.37153472])