function medianAbsoluteDeviation(x) {
    const medianValue = median(x);
    const medianAbsoluteDeviations = [];

    // Make a list of absolute deviations from the median
    for (let i = 0; i < x.length; i++) {
        medianAbsoluteDeviations.push(Math.abs(x[i] - medianValue));
    }

    // Find the median value of that list
    return median(medianAbsoluteDeviations);
}
The [Median Absolute Deviation](http://en.wikipedia.org/wiki/Median_absolute_deviation) is
a robust measure of statistical
dispersion. It is more resilient to outliers than the standard deviation.

@param {Array<number>} x input array
@returns {number} median absolute deviation
@example
medianAbsoluteDeviation([1, 1, 2, 2, 4, 6, 9]); // => 1