me

HydroErr.HydroErr.me(simulated_array, observed_array, replace_nan=None, replace_inf=None, remove_neg=False, remove_zero=False)

Compute the mean error of the simulated and observed data.

../_images/ME.png

Range: -inf < MAE < inf, data units, closer to zero is better, indicates bias.

Notes: The mean error (ME) measures the difference between the simulated data and the observed data. For the mean error, a smaller number indicates a better fit to the original data. Note that if the error is in the form of random noise, the mean error will be very small, which can skew the accuracy of this metric. ME is cumulative and will be small even if there are large positive and negative errors that balance.

Parameters:
  • simulated_array (one dimensional ndarray) – An array of simulated data from the time series.
  • observed_array (one dimensional ndarray) – An array of observed data from the time series.
  • replace_nan (float, optional) – If given, indicates which value to replace NaN values with in the two arrays. If None, when a NaN value is found at the i-th position in the observed OR simulated array, the i-th value of the observed and simulated array are removed before the computation.
  • replace_inf (float, optional) – If given, indicates which value to replace Inf values with in the two arrays. If None, when an inf value is found at the i-th position in the observed OR simulated array, the i-th value of the observed and simulated array are removed before the computation.
  • remove_neg (boolean, optional) – If True, when a negative value is found at the i-th position in the observed OR simulated array, the i-th value of the observed AND simulated array are removed before the computation.
  • remove_zero (boolean, optional) – If true, when a zero value is found at the i-th position in the observed OR simulated array, the i-th value of the observed AND simulated array are removed before the computation.
Returns:

The mean error value.

Return type:

float

Examples

Note that in this example the random noise cancels, leaving a very small ME.

>>> import HydroErr as he
>>> import numpy as np
>>> # Seed for reproducibility
>>> np.random.seed(54839)
>>> x = np.arange(100) / 20
>>> sim = np.sin(x) + 2
>>> obs = sim * (((np.random.rand(100) - 0.5) / 10) + 1)
>>> he.me(sim, obs)
-0.006832220968967168

References

  • Fisher, R.A., 1920. A Mathematical Examination of the Methods of Determining the Accuracy of an Observation by the Mean Error, and by the Mean Square Error. Monthly Notices of the Royal Astronomical Society 80 758 - 770.