scoringrules.twgksuv_ensemble#
- scoringrules.twgksuv_ensemble(obs: ArrayLike, fct: Array, a: float = -inf, b: float = inf, m_axis: int = -1, *, ens_w: Array = None, v_func: Callable[[ArrayLike], ArrayLike] = None, estimator: str = 'nrg', backend: Backend = None) Array#
Compute the Threshold-Weighted univariate Gaussian Kernel Score (GKS) for a finite ensemble.
Computation is performed using the ensemble representation of threshold-weighted kernel scores in [Allen et al. (2022)](https://arxiv.org/abs/2202.12732).
\[\mathrm{twGKS}(F_{ens}, y) = - \frac{1}{M} \sum_{m = 1}^{M} k(v(x_{m}), v(y)) + \frac{1}{2 M^{2}} \sum_{m = 1}^{M} \sum_{j = 1}^{M} k(v(x_{m}), v(x_{j})) + \frac{1}{2} k(v(y), v(y)),\]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, \(v\) is the chaining function used to target particular outcomes, and
\[k(x_{1}, x_{2}) = \exp \left(- \frac{(x_{1} - x_{2})^{2}}{2} \right)\]is the Gaussian kernel.
- 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
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.
- v_funccallable, array_like -> array_like
Chaining function used to emphasise particular outcomes. For example, a function that only considers values above a certain threshold \(t\) by projecting forecasts and observations to \([t, \inf)\).
- backendstr
The name of the backend used for computations. Defaults to ‘numba’ if available, else ‘numpy’.
- Returns:
- twgksarray_like
The twGKS between the forecast ensemble and obs for the chosen chaining function.
Examples
>>> import numpy as np >>> import scoringrules as sr >>> >>> def v_func(x): >>> return np.maximum(x, -1.0) >>> >>> sr.twgksuv_ensemble(obs, pred, v_func=v_func)