Ok, that means that the patches for Min and Max should be as follows:
For class Max:
public void increment(final double d)
{
if (!Double.isNaN(d))
value = (d > value) ? d : value;
n++;
}
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++)
{
if (!Double.isNaN(values[i]))
max = (max > values[i]) ? max : values[i];
}
}
return max;
}
and for class Min
public void increment(final double d)
{
if (!Double.isNaN(d))
value = (d < value) ? d : value;
n++;
}
public double evaluate(final double[] values,final int begin, final
int length)
{
double min = Double.NaN;
if (test(values, begin, length))
{
min = values[begin];
for (int i = begin; i < begin + length; i++)
{
if (!Double.isNaN(values[i]))
min = (min < values[i]) ? min : values[i];
}
}
return min;
}
Kim
Phil Steitz wrote:
This should be discussed in a separate ticket against the Complex
class (done now - 37086).
The general policy in [math] is to use NaN consistently with floating
point arithemtic specs (IEEE 754 for real, C99x Annex G for complex
arithmetic) so for statistics such as Sum, Mean, etc. that involve
arithmetic computations, NaN values force the return value to be NaN.
The Min and Max order statistics ignore NaNs. Slightly
inconsistently, the Percentile and Median order statistics use the
total ordering determined by Double.compareTo which considers NaN as
larger than any value (including Double.POSITIVE_INFINITY) and
consider NaNs in the computation. All of this is specified in the
javadoc for these statistics.
Phil
------- Additional Comments From [EMAIL PROTECTED] 2005-10-13 16:45 -------
The Complex class also has some questionable and undocumented behavior with
respect to NaN (and Inf). It might be worthwhile considering on a general NaN
policy for the math classes.
--
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
http://www.kimvdlinde.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]