The OpenD Programming Language

medianAbsoluteDeviation

Calculates the median absolute deviation about the median of the input.

By default, if F is not floating point type, then the result will have a double type if F is implicitly convertible to a floating point type.

Return Value

Type: meanType!(T[])

The median absolute deviation of the input

Examples

medianAbsoluteDeviation of vector

import mir.math.common: approxEqual;
import mir.ndslice.slice: sliced;

auto x = [0.0, 1.0, 1.5, 2.0, 3.5, 4.25,
          2.0, 7.5, 5.0, 1.0, 1.5, 0.0].sliced;

assert(x.medianAbsoluteDeviation.approxEqual(1.25));

Median Absolute Deviation of matrix

import mir.math.common: approxEqual;
import mir.ndslice.fuse: fuse;

auto x = [
    [0.0, 1.0, 1.5, 2.0, 3.5, 4.25],
    [2.0, 7.5, 5.0, 1.0, 1.5, 0.0]
].fuse;

assert(x.medianAbsoluteDeviation.approxEqual(1.25));

Median Absolute Deviation of dynamic array

import mir.math.common: approxEqual;

auto x = [0.0, 1.0, 1.5, 2.0, 3.5, 4.25,
          2.0, 7.5, 5.0, 1.0, 1.5, 0.0];

assert(x.medianAbsoluteDeviation.approxEqual(1.25));

Meta