PlotList { public double getAverage() { if (getSize() == 0) { return Double.NaN; } long sum = 0; double size = getSize(); for (int i = 0; i < size; i++) { sum += (getY(i)).longValue(); } return new BigDecimal(((double) sum) / size).setScale(2, BigDecimal.ROUND_FLOOR).doubleValue(); } PlotList(String pltfileName,String pngpath,String folderWhereResultsAreSaved,
			String xcomment,String ycomment,int scale,boolean issampled,String color, String unit);  PlotList(String pltfileName,String pngpath,String folderWhereResultsAreSaved,
			String xcomment,String ycomment,int scale,boolean issampled,String color, String unit, int type);  PlotList(String pltfileName,String pngpath,String folderWhereResultsAreSaved,
			String xcomment,String ycomment,int scale,boolean issampled,String color);  PlotList(); long getInitialValue(); void setScale(int scale); int getScale(); synchronized void addValue(Float y); synchronized void addValue(Long x, Float y); synchronized void changeTimeScale(Long x); synchronized void addNewlineinfile(long Xvalue, float YValue); void addNewlineinfile(long Xvalue,String YValue); void closefile(); Long getXScale(long range); Long getMin(); Long getMax(); double getAverage(); double getTotal(); double getDelta(); boolean isEmpty(); int getSize(); Long getX(int index); Float getY(int index); void setFolder(String folder); String getFolder(); void setYComment(String yComment); String getYComment(); void setXComment(String xComment); String getXComment(); File getPltfile(); void setPltfile(File pltfile); String getPngpath(); void setPngpath(String pngpath); boolean isSampled(); String getColor(); String getunit(); int getType(); static int TYPE_AVG; static int TYPE_SUM; }
@Test public void testGetAverage() { assertEquals(Double.NaN, list1.getAverage()); list1.addValue(-1L, 10F); list1.addValue(-2L, -3F); list1.addValue(30L, 3F); list1.addValue(2L, -100F); list1.addValue(31L, -102F); assertEquals(-29.67, list1.getAverage()); }