Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1398

Support simple Arithmetic mean without Compute correction factor in second pass?

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • 4.X
    • None
    • All

    Description

      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 }

      Attachments

        Activity

          People

            Unassigned Unassigned
            francis.li Francis Li
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: