org.matheclipse.core.stat.descriptive.summary
Class SymbolicSum
- java.lang.Object
-
- org.matheclipse.core.stat.descriptive.AbstractSymbolicStorelessUnivariateStatistic
-
- org.matheclipse.core.stat.descriptive.summary.SymbolicSum
-
- All Implemented Interfaces:
- java.io.Serializable, StorelessSymbolicUnivariateStatistic, SymbolicUnivariateStatistic
public class SymbolicSum extends AbstractSymbolicStorelessUnivariateStatistic implements java.io.Serializable
Returns the sum of the available values.If there are no values in the dataset, then
nullis 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()orclear()method, it must be synchronized externally.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description SymbolicSum()Create a Sum instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclear()Clears the internal state of the StatisticIExprevaluate(IAST values, IAST weights)The weighted sum of the entries in the the input array.IExprevaluate(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.IExprevaluate(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.longgetN()Returns the number of values that have been added.IExprgetResult()Returns the current value of the Statistic.voidincrement(IExpr d)Updates the internal state of the statistic to reflect the addition of the new value.-
Methods inherited from class org.matheclipse.core.stat.descriptive.AbstractSymbolicStorelessUnivariateStatistic
evaluate, incrementAll, incrementAll
-
-
-
-
Method Detail
-
increment
public void increment(IExpr d)
Updates the internal state of the statistic to reflect the addition of the new value.- Specified by:
incrementin interfaceStorelessSymbolicUnivariateStatistic- Specified by:
incrementin classAbstractSymbolicStorelessUnivariateStatistic- Parameters:
d- the new value.
-
getResult
public IExpr getResult()
Returns the current value of the Statistic.- Specified by:
getResultin interfaceStorelessSymbolicUnivariateStatistic- Specified by:
getResultin classAbstractSymbolicStorelessUnivariateStatistic- Returns:
- value of the statistic,
Double.NaNif it has been cleared or just instantiated.
-
getN
public long getN()
Returns the number of values that have been added.- Specified by:
getNin interfaceStorelessSymbolicUnivariateStatistic- Specified by:
getNin classAbstractSymbolicStorelessUnivariateStatistic- Returns:
- the number of values.
-
clear
public void clear()
Clears the internal state of the Statistic- Specified by:
clearin interfaceStorelessSymbolicUnivariateStatistic- Specified by:
clearin classAbstractSymbolicStorelessUnivariateStatistic
-
evaluate
public 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.Throws
IllegalArgumentExceptionif the array is null.- Specified by:
evaluatein interfaceSymbolicUnivariateStatistic- Overrides:
evaluatein classAbstractSymbolicStorelessUnivariateStatistic- Parameters:
values- the input arraybegin- index of the first array element to includelength- the number of elements to include- Returns:
- the sum of the values or 0 if length = 0
- Throws:
java.lang.IllegalArgumentException- if the array is null or the array index parameters are not valid- See Also:
UnivariateStatistic.evaluate(double[], int, int)
-
evaluate
public 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.Throws
IllegalArgumentExceptionif any of the following are true:- the values array is null
- the weights array is null
- the weights array does not have the same length as the values array
- the weights array contains one or more infinite values
- the weights array contains one or more NaN values
- the weights array contains negative values
- the start and length arguments do not determine a valid array
Uses the formula,
weighted sum = Σ(values[i] * weights[i])- Parameters:
values- the input arrayweights- the weights arraybegin- index of the first array element to includelength- the number of elements to include- Returns:
- the sum of the values or 0 if length = 0
- Throws:
java.lang.IllegalArgumentException- if the parameters are not valid- Since:
- 2.1
-
evaluate
public IExpr evaluate(IAST values, IAST weights)
The weighted sum of the entries in the the input array.Throws
IllegalArgumentExceptionif any of the following are true:- the values array is null
- the weights array is null
- the weights array does not have the same length as the values array
- the weights array contains one or more infinite values
- the weights array contains one or more NaN values
- the weights array contains negative values
Uses the formula,
weighted sum = Σ(values[i] * weights[i])- Parameters:
values- the input arrayweights- the weights array- Returns:
- the sum of the values or Double.NaN if length = 0
- Throws:
java.lang.IllegalArgumentException- if the parameters are not valid- Since:
- 2.1
-
-
DMelt 3.0 © DataMelt by jWork.ORG