scoringrules.crps_mixnorm#
- scoringrules.crps_mixnorm(obs: ArrayLike, m: ArrayLike, s: ArrayLike, w: ArrayLike = None, m_axis: ArrayLike = -1, *, backend: Backend = None) ArrayLike#
Compute the closed form of the CRPS for a mixture of normal distributions.
It is based on the following formulation from [1]:
\[\mathrm{CRPS}(F, y) = \sum_{i=1}^{M} w_{i} A(y - \mu_{i}, \sigma_{i}^{2}) - \frac{1}{2} \sum_{i=1}^{M} \sum_{j=1}^{M} w_{i} w_{j} A(\mu_{i} - \mu_{j}, \sigma_{i}^{2} + \sigma_{j}^{2}),\]where \(F(x) = \sum_{i=1}^{M} w_{i} \Phi \left( \frac{x - \mu_{i}}{\sigma_{i}} \right)\), and \(A(\mu, \sigma^{2}) = \mu (2 \Phi(\frac{\mu}{\sigma}) - 1) + 2\sigma \phi(\frac{\mu}{\sigma}).\)
- Parameters:
- obsarray_like
The observed values.
- m: array_like
Means of the component normal distributions.
- s: array_like
Standard deviations of the component normal distributions.
- w: array_like
Non-negative weights assigned to each component.
- m_axisint
The axis corresponding to the mixture components. Default is the last axis.
- backendstr, optional
The name of the backend used for computations. Defaults to
numbaif available, elsenumpy.
- Returns:
- crpsarray_like
The CRPS between MixNormal(m, s) and obs.
References
[1]Grimit, E.P., Gneiting, T., Berrocal, V.J. and Johnson, N.A. (2006), The continuous ranked probability score for circular variables and its application to mesoscale forecast ensemble verification. Q.J.R. Meteorol. Soc., 132: 2925-2942. https://doi.org/10.1256/qj.05.235
Examples
>>> import scoringrules as sr >>> sr.crps_mixnorm(0.0, [0.1, -0.3, 1.0], [0.4, 2.1, 0.7], [0.1, 0.2, 0.7]) 0.46806866729387275