scoringrules.crps_csg0#
- scoringrules.crps_csg0(obs: ArrayLike, shape: ArrayLike, rate: ArrayLike | None = None, *, scale: ArrayLike | None = None, shift: ArrayLike = 0.0, backend: Backend = None) ArrayLike#
Compute the closed form of the CRPS for the censored, shifted gamma distribution.
It is based on the following formulation from [1]:
\[\mathrm{CRPS}\bigl(F^0_{\alpha,\beta,\delta},\,y\bigr) = (y+\delta)\,\bigl(2F_{\alpha,\beta}(y+\delta)-1\bigr) - \frac{\alpha}{\beta\pi}\,B\!\Bigl(\tfrac12,\alpha+\tfrac12\Bigr)\,\bigl(1 - F_{2\alpha,\beta}(2\delta)\bigr) + \frac{\alpha}{\beta}\,\Bigl(1 + 2\,F_{\alpha,\beta}(\delta)\,F_{\alpha+1,\beta}(\delta) - F_{\alpha,\beta}(\delta)^2 - 2\,F_{\alpha+1,\beta}(y+\delta)\Bigr) - \delta\,\bigl(F_{\alpha,\beta}(\delta)\bigr)^{2},\]where \(F^0_{\alpha,\beta,\delta}\) is the censored, shifted gamma distribution function with shape parameter \(\alpha > 0\), rate parameter \(\beta > 0\) (equivalently, with scale parameter \(1/\beta\)) and shift parameter \(\delta > 0\).
- Parameters:
- obsarray_like
The observed values.
- shapearray_like
Shape parameter of the forecast CSG distribution.
- ratearray_like, optional
Rate parameter of the forecast CSG distribution. Either
rateorscalemust be provided.- scalearray_like, optional
Scale parameter of the forecast CSG distribution, where
scale = 1 / rate. Eitherrateorscalemust be provided.- shiftarray_like
Shift parameter of the forecast CSG distribution.
- backendstr, optional
The name of the backend used for computations. Defaults to
numbaif available, elsenumpy.
- Returns:
- crpsarray_like
The CRPS between obs and CSG(shape, rate, shift).
- Raises:
- ValueError
If both
rateandscaleare provided, or if neither is provided.
References
[1]Scheuerer, M., & Hamill, T. M. (2015). Statistical postprocessing of ensemble precipitation forecasts by fitting censored, shifted gamma distributions. Monthly Weather Review, 143(11), 4578-4596. https://doi.org/10.1175/MWR-D-15-0061.1
Examples
>>> import scoringrules as sr >>> sr.crps_csg0(0.7, shape=0.5, rate=2.0, shift=0.3) 0.5411044348806484