median

  1. T median(Slice!(RCI!T) data)
  2. T median(Slice!(const(T)*) data)
    @safe pure nothrow @nogc
    T
    median
    (
    T
    )
    (
    Slice!(const(T)*) data
    )

Examples

import mir.ndslice;
import mir.math;

auto a = mininitRcslice!double(3);
a[] = [3, 1, 7];
auto med = median!double(a.flattened);
assert(med == 3.0);
assert(a == [3, 1, 7]);//add in stddev out param
double aDev;
auto aCenter = centerColumns(a, aDev, MeanEstimator.median);
assert(aCenter == [0.0, -2.0, 4.0]);
assert(aDev == 3.0);
auto b = mininitRcslice!double(4);
b[] = [4,2,5,1];
auto medB = median!double(b.flattened);
assert(medB == 3.0);
assert(b == [4,2,5,1]);
double bDev;
auto bCenter = centerColumns(b, bDev, MeanEstimator.median);
assert(bCenter == [1.0, -1.0, 2.0, -2.0]);
assert(bDev == 3.0);

Meta