public class DoubleStatisticsSync extends Object implements DoubleStatistics
Implementation Note:
This implementation is thread-safe.
| Constructor and Description |
|---|
DoubleStatisticsSync()
Construct an empty instance with zero count, zero sum,
Double.POSITIVE_INFINITY min, Double.NEGATIVE_INFINITY
max and zero average. |
DoubleStatisticsSync(DoubleStatisticsSync other)
Constructs a non-empty instance with an initial state that corresponds to
the current state of the specified
other DoubleStatisticsSync
instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(double value)
Records another value into the summary information.
|
double |
getAverage()
Returns the arithmetic mean of values recorded, or zero if no values have
been recorded.
|
long |
getCount()
Return the count of values recorded.
|
double |
getMax()
Returns the maximum recorded value,
Double.NaN if any recorded
value was NaN or Double.NEGATIVE_INFINITY if no values were
recorded. |
double |
getMin()
Returns the minimum recorded value,
Double.NaN if any recorded
value was NaN or Double.POSITIVE_INFINITY if no values were
recorded. |
double |
getStandardDeviation() |
double |
getSum()
Returns the sum of values recorded, or zero if no values have been
recorded.
|
double |
getVariance() |
String |
toString()
Returns a non-empty string representation of this object suitable for
debugging.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitnewInstance, newInstancepublic DoubleStatisticsSync()
Double.POSITIVE_INFINITY min, Double.NEGATIVE_INFINITY
max and zero average.public DoubleStatisticsSync(DoubleStatisticsSync other) throws IllegalArgumentException
other DoubleStatisticsSync
instance.
If other.count is zero then the remaining arguments are ignored
and an empty instance is constructed.
If the state of other is inconsistent then an
IllegalArgumentException is thrown. The necessary conditions for
a consistent state are:
other.count >= 0(other.min <= other.max && !isNaN(other.sum)) || (isNaN(other.min) && isNaN(other.max) && isNaN(other.sum))
API Note:
The enforcement of state correctness means that the retrieved set of
recorded values obtained from a DoubleStatisticsSync source
instance may not be a legal state for this constructor due to arithmetic
overflow of the source's recorded count of values. The consistency
conditions are not sufficient to prevent the creation of an internally
inconsistent instance. An example of such a state would be an instance
with: other.count = 2, other.min = 1, other.max =
2, and other.sum = 0.
other - the DoubleStatisticsSync instance whose state should be
replicatedNullPointerException - if other is nullIllegalArgumentException - if the internal state of the other object is
inconsistentpublic void accept(double value)
accept in interface DoubleStatisticsvalue - the input valuepublic final long getCount()
getCount in interface DoubleStatisticspublic final double getSum()
The value of a floating-point sum is a function both of the input values
as well as the order of addition operations. The order of addition
operations of this method is intentionally not defined to allow for
implementation flexibility to improve the speed and accuracy of the
computed result.
In particular, this method may be implemented using compensated summation
or other technique to reduce the error bound in the numerical sum
compared to a simple summation of double values. Because of the
unspecified order of operations and the possibility of using differing
summation schemes, the output of this method may vary on the same input
values.
Various conditions can result in a non-finite sum being computed. This can occur even if the all the recorded values being summed are finite. If any recorded value is non-finite, the sum will be non-finite:
API Note:
Values sorted by increasing absolute magnitude tend to yield more
accurate results.
getSum in interface DoubleStatisticspublic final double getMin()
Double.NaN if any recorded
value was NaN or Double.POSITIVE_INFINITY if no values were
recorded. Unlike the numerical comparison operators, this method
considers negative zero to be strictly smaller than positive zero.getMin in interface DoubleStatisticsDouble.NaN if any recorded
value was NaN or Double.POSITIVE_INFINITY if no values
were recordedpublic final double getMax()
Double.NaN if any recorded
value was NaN or Double.NEGATIVE_INFINITY if no values were
recorded. Unlike the numerical comparison operators, this method
considers negative zero to be strictly smaller than positive zero.getMax in interface DoubleStatisticsDouble.NaN if any recorded
value was NaN or Double.NEGATIVE_INFINITY if no values
were recordedpublic final double getAverage()
The computed average can vary numerically and have the special case
behavior as computing the sum; see DoubleStatistics.getSum() for details.
API Note:
Values sorted by increasing absolute magnitude tend to yield more
accurate results.
getAverage in interface DoubleStatisticspublic final double getVariance()
getVariance in interface DoubleStatisticspublic final double getStandardDeviation()
getStandardDeviation in interface DoubleStatisticspublic String toString()
toString in interface DoubleStatisticstoString in class ObjectCopyright © 2022. All rights reserved.