The OpenD Programming Language

CorrelationAccumulator

  1. struct CorrelationAccumulator(T, CorrelationAlgo correlationAlgo, Summation summation)
    struct CorrelationAccumulator (
    T
    CorrelationAlgo correlationAlgo
    Summation summation
    ) if (
    isMutable!T &&
    correlationAlgo == CorrelationAlgo.naive
    ) {}
  2. struct CorrelationAccumulator(T, CorrelationAlgo correlationAlgo, Summation summation)
  3. struct CorrelationAccumulator(T, CorrelationAlgo correlationAlgo, Summation summation)
  4. struct CorrelationAccumulator(T, CorrelationAlgo correlationAlgo, Summation summation)
  5. struct CorrelationAccumulator(T, CorrelationAlgo correlationAlgo, Summation summation)

Constructors

this
this(RangeX x, RangeY y)

Members

Aliases

S
alias S = Summator!(T, summation)

Functions

centeredSumOfProducts
F centeredSumOfProducts()
centeredSumOfSquaresLeft
F centeredSumOfSquaresLeft()
centeredSumOfSquaresRight
F centeredSumOfSquaresRight()
correlation
F correlation()
count
size_t count()
covariance
F covariance(bool isPopulation)
meanLeft
F meanLeft()
meanRight
F meanRight()
put
void put(Slice!(IteratorX, 1, kindX) x, Slice!(IteratorY, 1, kindY) y)
put
void put(SliceLikeX x, SliceLikeY y)
put
void put(RangeX x, RangeY y)
put
void put(T x, T y)
put
void put(CorrelationAccumulator!(U, correlationAlgo, sumAlgo) v)
sumLeft
F sumLeft()
sumOfProducts
F sumOfProducts()
sumOfSquaresLeft
F sumOfSquaresLeft()
sumOfSquaresRight
F sumOfSquaresRight()
sumRight
F sumRight()

Variables

summatorLeft
S summatorLeft;
summatorOfProducts
S summatorOfProducts;
summatorOfSquaresLeft
S summatorOfSquaresLeft;
summatorOfSquaresRight
S summatorOfSquaresRight;
summatorRight
S summatorRight;

Examples

import mir.math.sum: Summation;
import mir.ndslice.slice: sliced;
import mir.test: shouldApprox;

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;
auto y = [-0.75,   6.0, -0.25, 8.25, 5.75,  3.5,
           9.25, -0.75,   2.5, 1.25,   -1, 2.25].sliced;

CorrelationAccumulator!(double, CorrelationAlgo.naive, Summation.naive) v;
v.put(x, y);

v.covariance(true).shouldApprox == 82.25 / 12 - (29.25 * 36) / (12 * 12);
v.covariance(false).shouldApprox == 82.25 / 11 - (29.25 * 36) / (12 * 12) * (12.0 / 11);

v.correlation.shouldApprox == -0.0623684;

v.put(4.0, 3.0);
v.covariance(true).shouldApprox == 94.25 / 13 - (33.25 * 39) / (13 * 13);
v.covariance(false).shouldApprox == 94.25 / 12 - (33.25 * 39) / (13 * 13) * (13.0 / 12);

v.correlation.shouldApprox == -0.0611234;

Meta