1 16 package org.apache.commons.math.stat.descriptive.rank; 17 18 import java.io.Serializable ; 19 20 import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic; 21 22 39 public class Min extends AbstractStorelessUnivariateStatistic implements Serializable { 40 41 42 static final long serialVersionUID = -2941995784909003131L; 43 44 45 private long n; 46 47 48 private double value; 49 50 53 public Min() { 54 n = 0; 55 value = Double.NaN; 56 } 57 58 61 public void increment(final double d) { 62 if (d < value || Double.isNaN(value)) { 63 value = d; 64 } 65 n++; 66 } 67 68 71 public void clear() { 72 value = Double.NaN; 73 n = 0; 74 } 75 76 79 public double getResult() { 80 return value; 81 } 82 83 86 public long getN() { 87 return n; 88 } 89 90 112 public double evaluate(final double[] values,final int begin, final int length) { 113 double min = Double.NaN; 114 if (test(values, begin, length)) { 115 min = values[begin]; 116 for (int i = begin; i < begin + length; i++) { 117 min = (min < values[i]) ? min : values[i]; 118 } 119 } 120 return min; 121 } 122 } | Popular Tags |