Uses a SumOfLogs instance to compute sum of logs and returns
exp( 1/n (sum of logs) ). Therefore,
NaN.Double.POSITIVE_INFINITY, but at least one value is 0, the
result is 0.Double.POSITIVE_INFINITY and
Double.NEGATIVE_INFINITY are among the values, the result is
NaN.
Note that this implementation is not synchronized. If
multiple threads access an instance of this class concurrently, and at least
one of the threads invokes the increment() or
clear() method, it must be synchronized externally.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Serializable version identifier |
| private StorelessUnivariateStatistic | sumOfLogs
Wrapped SumOfLogs instance |
| Access | Constructor and Description |
|---|---|
| public | |
| public | GeometricMean(GeometricMean
the original)GeometricMean instance to copyCopy constructor, creates a new |
| public | GeometricMean(SumOfLogs
sum of logs instance to use for computation sumOfLogs)Create a GeometricMean instance using the given SumOfLogs instance |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public void | clear()
Implements abstract org. Implements org. Clears the internal state of the Statistic |
| public GeometricMean | copy()
Implements abstract org. Implements org. Returns a copy of the statistic with the same internal state. |
| public static void | copy(GeometricMean
GeometricMean to copy source, GeometricMean GeometricMean to copy to dest)Copies source to dest. |
| public double | Returns: the geometric mean or Double.NaN if length = 0 or any of the values are <= 0.input array containing the values values, final int first array element to include begin, final int the number of elements to include length)Overrides org. Implements org. Returns the geometric mean of the entries in the specified portion of the input array. |
| public long | getN()
Implements org. Returns the number of values that have been added. |
| public double | getResult()
Implements abstract org. Implements org. Returns the current value of the Statistic. |
| public StorelessUnivariateStatistic | Returns: the StorelessUnivariateStatistic implementing the log sumReturns the currently configured sum of logs implementation |
| public void | increment(final double
the new value. d)Implements abstract org. Implements org. Updates the internal state of the statistic to reflect the addition of the new value. |
| public void | setSumLogImpl(StorelessUnivariateStatistic
the StorelessUnivariateStatistic instance to use
for computing the log sum sumLogImpl)Sets the implementation for the sum of logs. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serializable version identifier | |
| sumOfLogs | back to summary |
|---|---|
| private StorelessUnivariateStatistic sumOfLogs Wrapped SumOfLogs instance | |
| GeometricMean | back to summary |
|---|---|
| public GeometricMean() Create a GeometricMean instance | |
| GeometricMean | back to summary |
|---|---|
| public GeometricMean(GeometricMean original) throws NullArgumentException Copy constructor, creates a new
| |
| GeometricMean | back to summary |
|---|---|
| public GeometricMean(SumOfLogs sumOfLogs) Create a GeometricMean instance using the given SumOfLogs instance
| |
| checkEmpty | back to summary |
|---|---|
| private void checkEmpty() throws MathIllegalStateException Throws MathIllegalStateException if n > 0.
| |
| clear | back to summary |
|---|---|
| public void clear() Implements abstract org. Implements org. Doc from org. Clears the internal state of the Statistic
| |
| copy | back to summary |
|---|---|
| public GeometricMean copy() Implements abstract org. Implements org. Doc from org. Returns a copy of the statistic with the same internal state.
| |
| copy | back to summary |
|---|---|
| public static void copy(GeometricMean source, GeometricMean dest) throws NullArgumentException Copies source to dest. Neither source nor dest can be null.
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, final int begin, final int length) throws MathIllegalArgumentException Overrides org. Implements org. Returns the geometric mean of the entries in the specified portion of the input array.
See
Throws
| |
| getN | back to summary |
|---|---|
| public long getN() Implements org. Doc from org. Returns the number of values that have been added.
| |
| getResult | back to summary |
|---|---|
| public double getResult() Implements abstract org. Implements org. Doc from org. Returns the current value of the Statistic.
| |
| getSumLogImpl | back to summary |
|---|---|
| public StorelessUnivariateStatistic getSumLogImpl() Returns the currently configured sum of logs implementation
| |
| increment | back to summary |
|---|---|
| public void increment(final double d) Implements abstract org. Implements org. Doc from org. Updates the internal state of the statistic to reflect the addition of the new value.
| |
| setSumLogImpl | back to summary |
|---|---|
| public void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl) throws MathIllegalStateException Sets the implementation for the sum of logs. This method must be activated before any data has been added - i.e.,
before
| |