commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Francis Li (JIRA)" <j...@apache.org>
Subject [jira] [Created] (MATH-1398) Support simple Arithmetic mean without Compute correction factor in second pass?
Date Sun, 27 Nov 2016 02:33:58 GMT
Francis Li  created MATH-1398:
---------------------------------

             Summary: 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 


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.4#6332)

Mime
View raw message