ens_mse

hydrostats.ens_metrics.ens_mse(obs: ndarray[tuple[Any, ...], dtype[floating | integer]], fcst_ens: ndarray[tuple[Any, ...], dtype[floating | integer]], remove_zero: bool = False, remove_neg: bool = False, reference: Literal['mean', 'median'] = 'mean') floating[Any]

Calculate the mean squared error between observed values and the ensemble mean.

Parameters:
  • obs – Array of observations for each start date.

  • fcst_ens – Array of ensemble forecast of dimension n x M, where n = number of start dates and M = number of ensemble members.

  • remove_neg – If True, when a negative value is found at the i-th position in the observed OR ensemble array, the i-th value of the observed AND ensemble array are removed before the computation.

  • remove_zero – If true, when a zero value is found at the i-th position in the observed OR ensemble array, the i-th value of the observed AND ensemble array are removed before the computation.

  • reference – Determines the reference series against which to calculate the error. Choices are ‘mean’ and ‘median’.

Returns:

The mean error between the observed time series data and the ensemble mean.

Return type:

float

Examples

>>> import numpy as np
>>> import hydrostats.ens_metrics as em
>>> np.random.seed(3849590438)

Creating an observed 1D array and an ensemble 2D array

>>> ensemble_array = (np.random.rand(100, 52) + 1) * 100  # 52 Ensembles
>>> observed_array = (np.random.rand(100) + 1) * 100

Computing the MSE between the ensemble mean and the observed data

>>> em.ens_mse(obs=observed_array, fcst_ens=ensemble_array)
910.5648405687582