normalizeColumns

Normalization of raw data.

  1. Slice!(RCI!T, 2) normalizeColumns(Slice!(const(T)*, 2, kind) matrix, Slice!(RCI!T) stdDev, DeviationEstimator devEst)
    @safe pure nothrow @nogc
    Slice!(RCI!T, 2)
    normalizeColumns
    (
    T
    SliceKind kind
    )
    (
    auto ref const Slice!(const(T)*, 2, kind) matrix
    ,
    out Slice!(RCI!T) stdDev
    ,)
  2. Slice!(RCI!T, 2) normalizeColumns(Slice!(RCI!T, 2, kind) matrix, Slice!(RCI!T) stdDev, DeviationEstimator devEst)

Parameters

matrix Slice!(const(T)*, 2, kind)

input M x N matrix, each row an observation and each column mean centred

stdDev Slice!(RCI!T)

column standard deviation

devEst DeviationEstimator

estimation method

Return Value

Type: Slice!(RCI!T, 2)

M x N matrix with each column divided by it's standard deviation

Examples

import mir.ndslice;
import mir.math;

auto data = mininitRcslice!double(2,2);
data[] = [[ 2, -1],
          [-2,  1]];
//sd1 = 2 * sqrt(2.0);
//sd2 = sqrt(2.0);
auto x = 1.0 / sqrt(2.0);
auto scaled = mininitRcslice!double(2,2);
scaled[] = [[ x, -x],
            [-x,  x]];
auto stdDev = mininitRcslice!double(2);
assert(normalizeColumns(data, stdDev) == scaled);
assert(stdDev == [2*sqrt(2.0), sqrt(2.0)]);

Meta