List of usage examples for org.apache.commons.math.stat.descriptive.moment Mean incrementAll
public void incrementAll(double[] values)
From source file:com.joliciel.jochre.graphics.ShapeImpl.java
double getBrightnessMeanBySector(String key, SectionBrightnessMeasurementMethod measurementMethod) { Map<SectionBrightnessMeasurementMethod, Double> methodToMeanMap = this.brightnessMeanBySectorMap.get(key); if (methodToMeanMap == null) { methodToMeanMap = new HashMap<Shape.SectionBrightnessMeasurementMethod, Double>(); this.brightnessMeanBySectorMap.put(key, methodToMeanMap); }//from w w w . j a v a 2 s . c o m Double brightnessMeanBySectorObj = methodToMeanMap.get(measurementMethod); double brightnessMeanBySector = 0.0; if (brightnessMeanBySectorObj == null) { Mean mean = new Mean(); Map<SectionBrightnessMeasurementMethod, double[][]> brightnessByMethod = this.brightnessBySectorMap .get(key); double[][] brightnessGrid = brightnessByMethod.get(measurementMethod); for (int i = 0; i < brightnessGrid.length; i++) mean.incrementAll(brightnessGrid[i]); brightnessMeanBySector = mean.getResult(); methodToMeanMap.put(measurementMethod, brightnessMeanBySector); } else { brightnessMeanBySector = brightnessMeanBySectorObj.doubleValue(); } return brightnessMeanBySector; }