public class SymbolicSum extends AbstractSymbolicStorelessUnivariateStatistic implements java.io.Serializable
If there are no values in the dataset, then null
is returned.
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.
Constructor and Description |
---|
SymbolicSum()
Create a Sum instance
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the internal state of the Statistic
|
IExpr |
evaluate(IAST values,
IAST weights)
The weighted sum of the entries in the the input array.
|
IExpr |
evaluate(IAST values,
IAST weights,
int begin,
int length)
The weighted sum of the entries in the specified portion of the input
array, or 0 if the designated subarray is empty.
|
IExpr |
evaluate(IAST values,
int begin,
int length)
The sum of the entries in the specified portion of the input array, or 0 if
the designated subarray is empty.
|
long |
getN()
Returns the number of values that have been added.
|
IExpr |
getResult()
Returns the current value of the Statistic.
|
void |
increment(IExpr d)
Updates the internal state of the statistic to reflect the addition of the
new value.
|
evaluate, incrementAll, incrementAll, test, test, test, test
public void increment(IExpr d)
increment
in interface StorelessSymbolicUnivariateStatistic
increment
in class AbstractSymbolicStorelessUnivariateStatistic
d
- the new value.public IExpr getResult()
getResult
in interface StorelessSymbolicUnivariateStatistic
getResult
in class AbstractSymbolicStorelessUnivariateStatistic
Double.NaN
if it has been
cleared or just instantiated.public long getN()
getN
in interface StorelessSymbolicUnivariateStatistic
getN
in class AbstractSymbolicStorelessUnivariateStatistic
public void clear()
clear
in interface StorelessSymbolicUnivariateStatistic
clear
in class AbstractSymbolicStorelessUnivariateStatistic
public IExpr evaluate(IAST values, int begin, int length)
Throws IllegalArgumentException
if the array is null.
evaluate
in interface SymbolicUnivariateStatistic
evaluate
in class AbstractSymbolicStorelessUnivariateStatistic
values
- the input arraybegin
- index of the first array element to includelength
- the number of elements to includejava.lang.IllegalArgumentException
- if the array is null or the array index parameters are not validUnivariateStatistic.evaluate(double[],
int, int)
public IExpr evaluate(IAST values, IAST weights, int begin, int length)
Throws IllegalArgumentException
if any of the following are
true:
Uses the formula,
weighted sum = Σ(values[i] * weights[i])
values
- the input arrayweights
- the weights arraybegin
- index of the first array element to includelength
- the number of elements to includejava.lang.IllegalArgumentException
- if the parameters are not validpublic IExpr evaluate(IAST values, IAST weights)
Throws IllegalArgumentException
if any of the following are
true:
Uses the formula,
weighted sum = Σ(values[i] * weights[i])
values
- the input arrayweights
- the weights arrayjava.lang.IllegalArgumentException
- if the parameters are not valid