def mad(arr, relative=True):
with warnings.catch_warnings():<EOL><INDENT>warnings.simplefilter("<STR_LIT:ignore>")<EOL>med = np.nanmedian(arr, axis=<NUM_LIT:1>)<EOL>mad = np.nanmedian(np.abs(arr - med[:, np.newaxis]), axis=<NUM_LIT:1>)<EOL>if relative:<EOL><INDENT>return mad / med<EOL><DEDENT>else:<EOL><INDENT>return mad<EOL><DEDENT><DEDENT>
Median Absolute Deviation: a "Robust" version of standard deviation.
        Indices variabililty of the sample.
        https://en.wikipedia.org/wiki/Median_absolute_deviation