94 * @throws NullPointerException if {@code other} is null 95 */ 96 public void combine(DoubleSummaryStatistics other) { 97 count += other.count; 98 sum += other.sum; 99 min = Math.min(min, other.min); 100 max = Math.max(max, other.max); 101 } 102 103 /** 104 * Return the count of values recorded. 105 * 106 * @return the count of values 107 */ 108 public final long getCount() { 109 return count; 110 } 111 112 /** 113 * Returns the sum of values recorded, or zero if no values have been 114 * recorded. The sum returned can vary depending upon the order in which 115 * values are recorded. This is due to accumulated rounding error in 116 * addition of values of differing magnitudes. Values sorted by increasing 117 * absolute magnitude tend to yield more accurate results. If any recorded 118 * value is a {@code NaN} or the sum is at any point a {@code NaN} then the 119 * sum will be {@code NaN}. 120 * 121 * @return the sum of values, or zero if none 122 */ 123 public final double getSum() { 124 return sum; 125 } 126 127 /** 128 * Returns the minimum recorded value, {@code Double.NaN} if any recorded 129 * value was NaN or {@code Double.POSITIVE_INFINITY} if no values were 130 * recorded. Unlike the numerical comparison operators, this method 131 * considers negative zero to be strictly smaller than positive zero. 132 * 133 * @return the minimum recorded value, {@code Double.NaN} if any recorded 134 * value was NaN or {@code Double.POSITIVE_INFINITY} if no values were 135 * recorded 136 */ 137 public final double getMin() { 138 return min; 139 } 140 141 /** 142 * Returns the maximum recorded value, {@code Double.NaN} if any recorded 143 * value was NaN or {@code Double.NEGATIVE_INFINITY} if no values were 144 * recorded. Unlike the numerical comparison operators, this method 145 * considers negative zero to be strictly smaller than positive zero. 146 * 147 * @return the maximum recorded value, {@code Double.NaN} if any recorded 148 * value was NaN or {@code Double.NEGATIVE_INFINITY} if no values were 149 * recorded 150 */ 151 public final double getMax() { 152 return max; 153 } 154 155 /** 156 * Returns the arithmetic mean of values recorded, or zero if no values have been 157 * recorded. The average returned can vary depending upon the order in 158 * which values are recorded. This is due to accumulated rounding error in 159 * addition of values of differing magnitudes. Values sorted by increasing 160 * absolute magnitude tend to yield more accurate results. If any recorded 161 * value is a {@code NaN} or the sum is at any point a {@code NaN} then the 162 * average will be {@code NaN}. 163 * 164 * @return the arithmetic mean of values, or zero if none 165 */ 166 public final double getAverage() { 167 return getCount() > 0 ? getSum() / getCount() : 0.0d; 168 } 169 170 /** 171 * {@inheritDoc} 172 * 173 * Returns a non-empty string representation of this object suitable for 174 * debugging. The exact presentation format is unspecified and may vary 175 * between implementations and versions. 176 */ 177 @Override 178 public String toString() { 179 return String.format( 180 "%s{count=%d, sum=%f, min=%f, average=%f, max=%f}", 181 this.getClass().getSimpleName(), 182 getCount(), | 94 * @throws NullPointerException if {@code other} is null 95 */ 96 public void combine(DoubleSummaryStatistics other) { 97 count += other.count; 98 sum += other.sum; 99 min = Math.min(min, other.min); 100 max = Math.max(max, other.max); 101 } 102 103 /** 104 * Return the count of values recorded. 105 * 106 * @return the count of values 107 */ 108 public final long getCount() { 109 return count; 110 } 111 112 /** 113 * Returns the sum of values recorded, or zero if no values have been 114 * recorded. 115 * 116 * If any recorded value is a NaN or the sum is at any point a NaN 117 * then the sum will be NaN. 118 * 119 * <p> The value of a floating-point sum is a function both of the 120 * input values as well as the order of addition operations. The 121 * order of addition operations of this method is intentionally 122 * not defined to allow for implementation flexibility to improve 123 * the speed and accuracy of the computed result. 124 * 125 * In particular, this method may be implemented using compensated 126 * summation or other technique to reduce the error bound in the 127 * numerical sum compared to a simple summation of {@code double} 128 * values. 129 * 130 * @apiNote Sorting values by increasing absolute magnitude tends to yield 131 * more accurate results. 132 * 133 * @return the sum of values, or zero if none 134 */ 135 public final double getSum() { 136 return sum; 137 } 138 139 /** 140 * Returns the minimum recorded value, {@code Double.NaN} if any recorded 141 * value was NaN or {@code Double.POSITIVE_INFINITY} if no values were 142 * recorded. Unlike the numerical comparison operators, this method 143 * considers negative zero to be strictly smaller than positive zero. 144 * 145 * @return the minimum recorded value, {@code Double.NaN} if any recorded 146 * value was NaN or {@code Double.POSITIVE_INFINITY} if no values were 147 * recorded 148 */ 149 public final double getMin() { 150 return min; 151 } 152 153 /** 154 * Returns the maximum recorded value, {@code Double.NaN} if any recorded 155 * value was NaN or {@code Double.NEGATIVE_INFINITY} if no values were 156 * recorded. Unlike the numerical comparison operators, this method 157 * considers negative zero to be strictly smaller than positive zero. 158 * 159 * @return the maximum recorded value, {@code Double.NaN} if any recorded 160 * value was NaN or {@code Double.NEGATIVE_INFINITY} if no values were 161 * recorded 162 */ 163 public final double getMax() { 164 return max; 165 } 166 167 /** 168 * Returns the arithmetic mean of values recorded, or zero if no 169 * values have been recorded. 170 * 171 * If any recorded value is a NaN or the sum is at any point a NaN 172 * then the average will be code NaN. 173 * 174 * <p>The average returned can vary depending upon the order in 175 * which values are recorded. 176 * 177 * This method may be implemented using compensated summation or 178 * other technique to reduce the error bound in the {@link #getSum 179 * numerical sum} used to compute the average. 180 * 181 * @apiNote Values sorted by increasing absolute magnitude tend to yield 182 * more accurate results. 183 * 184 * @return the arithmetic mean of values, or zero if none 185 */ 186 public final double getAverage() { 187 return getCount() > 0 ? getSum() / getCount() : 0.0d; 188 } 189 190 /** 191 * {@inheritDoc} 192 * 193 * Returns a non-empty string representation of this object suitable for 194 * debugging. The exact presentation format is unspecified and may vary 195 * between implementations and versions. 196 */ 197 @Override 198 public String toString() { 199 return String.format( 200 "%s{count=%d, sum=%f, min=%f, average=%f, max=%f}", 201 this.getClass().getSimpleName(), 202 getCount(), |