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;
enum PopulationTrueCT = true;
enum PopulationFalseCT = false;
bool PopulationTrueRT = true;
bool PopulationFalseRT = false;
VarianceAccumulator!(double, VarianceAlgo.online, Summation.naive) v;
v.put(x);
assert(v.variance(PopulationTrueRT).approxEqual(54.76562 / 12));
assert(v.variance(PopulationTrueCT).approxEqual(54.76562 / 12));
assert(v.variance(PopulationFalseRT).approxEqual(54.76562 / 11));
assert(v.variance(PopulationFalseCT).approxEqual(54.76562 / 11));
v.put(4.0);
assert(v.variance(PopulationTrueRT).approxEqual(57.01923 / 13));
assert(v.variance(PopulationTrueCT).approxEqual(57.01923 / 13));
assert(v.variance(PopulationFalseRT).approxEqual(57.01923 / 12));
assert(v.variance(PopulationFalseCT).approxEqual(57.01923 / 12));
import mir.math.common: approxEqual;
import mir.ndslice.slice: sliced;
auto x = [0.0, 1.0, 1.5, 2.0, 3.5, 4.25].sliced;
auto y = [2.0, 7.5, 5.0, 1.0, 1.5, 0.0].sliced;
enum PopulationTrueCT = true;
enum PopulationFalseCT = false;
bool PopulationTrueRT = true;
bool PopulationFalseRT = false;
VarianceAccumulator!(double, VarianceAlgo.online, Summation.naive) v;
v.put(x);
assert(v.variance(PopulationTrueRT).approxEqual(12.55208 / 6));
assert(v.variance(PopulationTrueCT).approxEqual(12.55208 / 6));
assert(v.variance(PopulationFalseRT).approxEqual(12.55208 / 5));
assert(v.variance(PopulationFalseCT).approxEqual(12.55208 / 5));
v.put(y);
assert(v.variance(PopulationTrueRT).approxEqual(54.76562 / 12));
assert(v.variance(PopulationTrueCT).approxEqual(54.76562 / 12));
assert(v.variance(PopulationFalseRT).approxEqual(54.76562 / 11));
assert(v.variance(PopulationFalseCT).approxEqual(54.76562 / 11));