import { xMedian } from "./xMedian.js";
/**
 * This function calculates the median absolute deviation (MAD).
 * https://en.wikipedia.org/wiki/Median_absolute_deviation
 * @param array - array of numbers.
 */
export function xMedianAbsoluteDeviation(array) {
    const median = xMedian(array);
    const averageDeviations = new Float64Array(array.length);
    for (let i = 0; i < array.length; i++) {
        averageDeviations[i] = Math.abs(array[i] - median);
    }
    return {
        median,
        mad: xMedian(averageDeviations),
    };
}
//# sourceMappingURL=xMedianAbsoluteDeviation.js.map