The OpenD Programming Language

CovarianceAccumulator

  1. struct CovarianceAccumulator(T, CovarianceAlgo covarianceAlgo, Summation summation)
  2. struct CovarianceAccumulator(T, CovarianceAlgo covarianceAlgo, Summation summation)
  3. struct CovarianceAccumulator(T, CovarianceAlgo covarianceAlgo, Summation summation)
    struct CovarianceAccumulator (
    T
    CovarianceAlgo covarianceAlgo
    Summation summation
    ) if (
    isMutable!T &&
    covarianceAlgo == CovarianceAlgo.twoPass
    ) {}
  4. struct CovarianceAccumulator(T, CovarianceAlgo covarianceAlgo, Summation summation)
  5. struct CovarianceAccumulator(T, CovarianceAlgo covarianceAlgo, Summation summation)

Constructors

this
this(Slice!(IteratorX, 1, kindX) x, Slice!(IteratorY, 1, kindY) y)
this
this(SliceLikeX x, SliceLikeY y)
this
this(RangeX x, RangeY y)
this
this(T x, T y)

Members

Aliases

S
alias S = Summator!(T, summation)

Functions

centeredSumOfProducts
F centeredSumOfProducts()
count
size_t count()
covariance
F covariance(bool isPopulation)
meanLeft
F meanLeft()
meanRight
F meanRight()
sumLeft
F sumLeft()
sumRight
F sumRight()

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;

auto v = CovarianceAccumulator!(double, CovarianceAlgo.twoPass, Summation.naive)(x, y);

v.covariance(true).shouldApprox == -5.5 / 12;
v.covariance(false).shouldApprox == -5.5 / 11;

Meta