fix some off-by-one errors

The number of elements in each half of the set was wrong, which broke
the calculations for mean and variance.  Also, the index used for
getting the cumulative sums was off-by-one.

These mean that we were reporting smaller sets with larger variances,
providing false positives to the change detector application logic.