variance method

double variance(
  1. Box cube
)

Implementation

double variance(Box cube) {
  final dr = volume(cube, momentsR);
  final dg = volume(cube, momentsG);
  final db = volume(cube, momentsB);
  final xx = moments[getIndex(cube.r1, cube.g1, cube.b1)] -
      moments[getIndex(cube.r1, cube.g1, cube.b0)] -
      moments[getIndex(cube.r1, cube.g0, cube.b1)] +
      moments[getIndex(cube.r1, cube.g0, cube.b0)] -
      moments[getIndex(cube.r0, cube.g1, cube.b1)] +
      moments[getIndex(cube.r0, cube.g1, cube.b0)] +
      moments[getIndex(cube.r0, cube.g0, cube.b1)] -
      moments[getIndex(cube.r0, cube.g0, cube.b0)];

  final hypotenuse = (dr * dr + dg * dg + db * db);
  final volume_ = volume(cube, weights);
  return xx - hypotenuse / volume_;
}