[ https://issues.apache.org/jira/browse/MATH-1398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rob Tompkins updated MATH-1398: ------------------------------- Fix Version/s: 4.X > Support simple Arithmetic mean without Compute correction factor in second > pass? > -------------------------------------------------------------------------------- > > Key: MATH-1398 > URL: https://issues.apache.org/jira/browse/MATH-1398 > Project: Commons Math > Issue Type: Improvement > Environment: All > Reporter: Francis Li > Labels: easyfix > Fix For: 4.X > > > The mean calculate by this function is different excel. which just sum/n as > first half of function. can we provide another option to calculate normal > means? > org.apache.commons.math3.stat.descriptive.moment.Mean > public double evaluate(final double[] values,final int begin, final int > length) > 163 throws MathIllegalArgumentException { > 164 if (test(values, begin, length)) { > 165 Sum sum = new Sum(); > 166 double sampleSize = length; > 167 > 168 // Compute initial estimate using definitional formula > 169 double xbar = sum.evaluate(values, begin, length) / sampleSize; > 170 > 171 // Compute correction factor in second pass > 172 double correction = 0; > 173 for (int i = begin; i < begin + length; i++) { > 174 correction += values[i] - xbar; > 175 } > 176 return xbar + (correction/sampleSize); > 177 } > 178 return Double.NaN; > 179 } -- This message was sent by Atlassian JIRA (v6.3.15#6346)