commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 37019] - [math] NaN handling in StatsUtil.min, StatsUtil.max methods
Date Thu, 13 Oct 2005 15:10:11 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37019>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37019





------- Additional Comments From kim@kimvdlinde.com  2005-10-13 17:10 -------
problem arrises from the underlying Max.evaluate(double[]) and
Min.evaluate(double[]) methods, who fail to address the Double.NaN values
similar to the Max.increment(double) methods, e.g. is not addressing it at all
(from class Max):

    public void increment(final double d) {
        if (d > value || Double.isNaN(value)) {
            value = d;
        }
        n++;
    }
and 
    (public double evaluate(final double[] values) is in super class, but
resolves to evaluate(values, 0, values.length) =>

    public double evaluate(final double[] values, final int begin, final int
length) {
        double max = Double.NaN;
        if (test(values, begin, length)) {
            max = values[begin];
            for (int i = begin; i < begin + length; i++) {
                max = (max > values[i]) ? max : values[i];
            }
        }
        return max;
    }

Solution:

    public double evaluate(final double[] values, final int begin, final int
length) {
        double max = Double.NaN;
        if (test(values, begin, length)) {
            max = values[begin];
            for (int i = begin; i < begin + length; i++) {
                max = ((max > values[i]) || Double.isNaN(value)) ? max : values[i];
            }
        }
        return max;
    }

similar to min and this will resolve issue in StatUtils.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message