scoringrules.crps_gev#
- scoringrules.crps_gev(obs: ArrayLike, shape: ArrayLike, location: ArrayLike = 0.0, scale: ArrayLike = 1.0, *, backend: Backend = None) ArrayLike#
Compute the closed form of the CRPS for the generalised extreme value (GEV) distribution.
It is based on the following formulation from [1]:
\[\text{CRPS}(F_{\xi, \mu, \sigma}, y) = \sigma \cdot \text{CRPS}(F_{\xi}, \frac{y - \mu}{\sigma})\]see Notes below for special cases.
- Parameters:
- obsarray_like
The observed values.
- shapearray_like
Shape parameter of the forecast GEV distribution.
- locationarray_like, optional
Location parameter of the forecast GEV distribution.
- scalearray_like, optional
Scale parameter of the forecast GEV distribution.
- backendstr, optional
The name of the backend used for computations. Defaults to
numbaif available, elsenumpy.
- Returns:
- crpsarray_like
The CRPS between obs and GEV(shape, location, scale).
Notes
Special cases are handled as follows:
For \(\xi = 0\):
\[\text{CRPS}(F_{\xi}, y) = -y - 2\text{Ei}(\log F_{\xi}(y)) + C - \log 2\]For \(\xi \neq 0\):
\[\text{CRPS}(F_{\xi}, y) = y(2F_{\xi}(y) - 1) - 2G_{\xi}(y) - \frac{1 - (2 - 2^{\xi}) \Gamma(1 - \xi)}{\xi}\]where \(C\) is the Euler-Mascheroni constant, \(\text{Ei}\) is the exponential integral, and \(\Gamma\) is the gamma function. The GEV cumulative distribution function \(F_{\xi}\) and the auxiliary function \(G_{\xi}\) are defined as:
For \(\xi = 0\):
\[F_{\xi}(x) = \exp(-\exp(-x))\]For \(\xi \neq 0\):
\[\begin{split}F_{\xi}(x) = \begin{cases} 0, & x \leq \frac{1}{\xi} \\ \exp(-(1 + \xi x)^{-1/\xi}), & x > \frac{1}{\xi} \end{cases}\end{split}\]\[\begin{split}G_{\xi}(x) = \begin{cases} 0, & x \leq \frac{1}{\xi} \\ \frac{F_{\xi}(x)}{\xi} + \frac{\Gamma_u(1-\xi, -\log F_{\xi}(x))}{\xi}, & x > \frac{1}{\xi} \end{cases}\end{split}\]References
[1]Friederichs, P., & Thorarinsdottir, T. L. (2012). A comparison of parametric and non-parametric methods for forecasting extreme events. Environmetrics, 23(7), 595-611. https://doi.org/10.1002/env.2176
Examples
>>> import scoringrules as sr >>> sr.crps_gev(0.3, 0.1) 0.2924712413052034