xskillscore.median_absolute_error

xskillscore.median_absolute_error(a, b, dim=None, skipna=False, keep_attrs=False)

Median Absolute Error.

\[\mathrm{median}(\vert a - b\vert)\]
Parameters:
  • a (xarray.Dataset or xarray.DataArray) – Labeled array(s) over which to apply the function.

  • b (xarray.Dataset or xarray.DataArray) – Labeled array(s) over which to apply the function.

  • dim (str, list) – The dimension(s) to apply the median absolute error along. Note that this dimension will be reduced as a result. Defaults to None reducing all dimensions.

  • skipna (bool) – If True, skip NaNs when computing function.

  • keep_attrs (bool) – If True, the attributes (attrs) will be copied from the first input to the new one. If False (default), the new object will be returned without attributes.

Returns:

Median Absolute Error.

Return type:

xarray.Dataset or xarray.DataArray

Examples

>>> a = xr.DataArray(np.random.rand(5, 3, 3), dims=["time", "x", "y"])
>>> b = xr.DataArray(np.random.rand(5, 3, 3), dims=["time", "x", "y"])
>>> xs.median_absolute_error(a, b, dim="time")
<xarray.DataArray (x: 3, y: 3)> Size: 72B
array([[0.28798217, 0.23322591, 0.62067468],
       [0.12146232, 0.20314509, 0.23442927],
       [0.59041981, 0.03289321, 0.21343494]])
Dimensions without coordinates: x, y