@Test public void testGetMean() { NewValue victim = new NewValue(); double test = victim.getMean(); assertTrue("getMean() on an uninitialized value should return NaN.", Double.isNaN(test)); double val1 = 1.1, val2 = 2.0; victim.push(val1); assertEquals("Value with one entry should return that entry for getMean", val1, victim.getMean(), EPSILON); victim.push(val2); double expectedResult = (val1 + val2) / 2.0; assertEquals("Value with two entries should return the average of the entries for getMean", expectedResult,victim.getMean(), EPSILON); Double [] testValues = new Double[] {1.0, -1.0, 2.0, 2.1, 0.0, 53.0, -27.5}; victim.clear(); for (double value : testValues) { victim.push(value); } double mean = getMean(testValues); assertEquals("Calculated variance should match variance from test object.", mean, victim.getMean(), EPSILON); }
public double getMean() { return (numDataValues > 0) ? newMean : Double.NaN; }
NewValue { public double getMean() { return (numDataValues > 0) ? newMean : Double.NaN; } }
NewValue { public double getMean() { return (numDataValues > 0) ? newMean : Double.NaN; }  }
NewValue { public double getMean() { return (numDataValues > 0) ? newMean : Double.NaN; }  void clear(); void push(double x); long getNumDataValues(); double getMean(); double getVariance(); double getStandardDeviation(); double getSum(); }
NewValue { public double getMean() { return (numDataValues > 0) ? newMean : Double.NaN; }  void clear(); void push(double x); long getNumDataValues(); double getMean(); double getVariance(); double getStandardDeviation(); double getSum();  }