### Question:
SelectionTool extends BasicTool { static double variance(double[] data) { int n = 0; double mean = 0.0; double m2 = 0.0; for (final double value : data) { if (!Double.isNaN(value)) { final double delta = value - mean; n++; mean = mean + delta / n; m2 = m2 + delta * (value - mean); } } if (n < 2) { return 0.0; } return m2 / (n - 1); } protected  SelectionTool(); static void main(String[] args); @Override void initialize();  }### Answer:
@Test public void testVariance_withZero() throws Exception { final double[] data = {0.0, 0.0, 0.0, 0.0, 0.0}; assertEquals(0.0, SelectionTool.variance(data), 0.0); }
@Test public void testVariance_withUnity() throws Exception { final double[] data = {1.0, 1.0, 1.0, 1.0, 1.0}; assertEquals(0.0, SelectionTool.variance(data), 0.0); }
@Test public void testVariance_withOtherNumbers() throws Exception { final double[] data = {1.0, 2.0, 3.0, 4.0, 5.0}; assertEquals(2.5, SelectionTool.variance(data), 0.0); }
@Test public void testVariance_withMoreNumbers() throws Exception { final double[] data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}; assertEquals(7.5, SelectionTool.variance(data), 0.0); }
@Test public void testVariance_withNaN() throws Exception { final double[] data = {Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN}; assertEquals(0.0, SelectionTool.variance(data), 0.0); }