scoringrules.crps_gamma

Contents

scoringrules.crps_gamma#

scoringrules.crps_gamma(obs: ArrayLike, shape: ArrayLike, rate: ArrayLike | None = None, *, scale: ArrayLike | None = None, backend: Backend = None) ArrayLike#

Compute the closed form of the CRPS for the gamma distribution.

It is based on the following formulation from [1]:

\[\mathrm{CRPS}(F_{\alpha, \beta}, y) = y(2F_{\alpha, \beta}(y) - 1) - \frac{\alpha}{\beta} (2 F_{\alpha + 1, \beta}(y) - 1) - \frac{1}{\beta B(1/2, \alpha)},\]

where \(F_{\alpha, \beta}\) is gamma distribution function with shape parameter \(\alpha > 0\) and rate parameter \(\beta > 0\) (equivalently, with scale parameter \(1/\beta\)).

Parameters:
obsarray_like

The observed values.

shape: array_like

Shape parameter of the forecast gamma distribution.

ratearray_like, optional

Rate parameter of the forecast rate distribution. Either rate or scale must be provided.

scalearray_like, optional

Scale parameter of the forecast scale distribution, where scale = 1 / rate. Either rate or scale must be provided.

backendstr, optional

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

Returns:
crps:

The CRPS between obs and Gamma(shape, rate).

Raises:
ValueError

If both rate and scale are provided, or if neither is provided.

References

[1]

Michael Scheuerer. David Möller. “Probabilistic wind speed forecasting on a grid based on ensemble model output statistics.” Ann. Appl. Stat. 9 (3) 1328 - 1349, September 2015. https://doi.org/10.1214/15-AOAS843

Examples

>>> import scoringrules as sr
>>> sr.crps_gamma(0.2, 1.1, 0.1)
5.503536008961291