spectrochempy.robust_scale๏ƒ

robust_scale(dataset, dim='y', inplace=False)[source]๏ƒ

Apply robust scaling along a dimension.

The data are centered on the median and scaled by the median absolute deviation (MAD). This makes the scaling resistant to outliers.

\[x_{ij}^\prime = \frac{x_{ij} - \mathrm{median}(x_j)}{\mathrm{MAD}(x_j)}\]

where \(\mathrm{MAD} = \mathrm{median}(|x - \mathrm{median}|)\) and the result is multiplied by 1.4826 so that the MAD estimates the standard deviation of a normal distribution.

Parameters:
  • dataset (NDDataset) โ€“ The input data.

  • dim (str or int, optional, default:โ€™yโ€™) โ€“ Dimension along which the median and MAD are computed.

  • inplace (bool, optional, default:False) โ€“ If True, scaling is performed in place.

Returns:

NDDataset โ€“ The robustly-scaled dataset.

Examples

>>> dataset = scp.read("irdata/nh4y-activation.spg")
>>> nd = dataset.robust_scale(dim="y")