类 Sum
java.lang.Object
org.hipparchus.stat.descriptive.AbstractStorelessUnivariateStatistic
org.hipparchus.stat.descriptive.summary.Sum
- 所有已实现的接口:
-
Serializable,DoubleConsumer,AggregatableStatistic<Sum>,StorelessUnivariateStatistic,UnivariateStatistic,WeightedEvaluation,MathArrays.Function
public class Sum extends AbstractStorelessUnivariateStatistic implements AggregatableStatistic<Sum>, WeightedEvaluation, Serializable
返回可用值的总和。
如果数据集中没有值,则返回0。如果任何值为NaN,则返回NaN。
请注意,此实现未同步。如果多个线程同时访问此类的实例,并且至少有一个线程调用increment()或clear()方法,则必须在外部进行同步。
- 另请参阅:
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明void将提供的实例聚合到此实例中。voidclear()清除统计数据的内部状态copy()返回具有相同内部状态的统计数据副本。doubleevaluate(double[] values, double[] weights, int begin, int length) 指定输入数组的指定部分的加权和,如果指定的子数组为空,则返回0。doubleevaluate(double[] values, int begin, int length) 指定输入数组的指定部分的总和,如果指定的子数组为空,则返回0。longgetN()返回已添加的值的数量。double返回统计数据的当前值。voidincrement(double d) 更新统计数据的内部状态以反映新值的添加。从类继承的方法 org.hipparchus.stat.descriptive.AbstractStorelessUnivariateStatistic
equals, hashCode, toString从接口继承的方法 org.hipparchus.stat.descriptive.AggregatableStatistic
aggregate, aggregate从接口继承的方法 java.util.function.DoubleConsumer
andThen从接口继承的方法 org.hipparchus.stat.descriptive.StorelessUnivariateStatistic
accept, incrementAll, incrementAll从接口继承的方法 org.hipparchus.stat.descriptive.UnivariateStatistic
evaluate从接口继承的方法 org.hipparchus.stat.descriptive.WeightedEvaluation
evaluate
-
构造器详细资料
-
Sum
public Sum()创建一个Sum实例。 -
Sum
复制构造函数,创建一个与原始Sum相同的新Sum。- 参数:
-
original- 要复制的Sum实例 - 抛出:
-
NullArgumentException- 如果original为null
-
-
方法详细资料
-
increment
public void increment(double d) 更新统计数据的内部状态以反映新值的添加。- 指定者:
-
increment在接口中StorelessUnivariateStatistic - 指定者:
-
increment在类中AbstractStorelessUnivariateStatistic - 参数:
-
d- 新值。
-
getResult
public double getResult()返回统计数据的当前值。- 指定者:
-
getResult在接口中StorelessUnivariateStatistic - 指定者:
-
getResult在类中AbstractStorelessUnivariateStatistic - 返回:
-
统计数据的值,如果已清除或刚实例化,则为
Double.NaN。
-
getN
public long getN()返回已添加的值的数量。- 指定者:
-
getN在接口中StorelessUnivariateStatistic - 返回:
- 值的数量。
-
clear
public void clear()清除统计数据的内部状态- 指定者:
-
clear在接口中StorelessUnivariateStatistic - 指定者:
-
clear在类中AbstractStorelessUnivariateStatistic
-
aggregate
将提供的实例聚合到此实例。此方法可用于合并计算在分区或子样本上的统计数据 - 即,此操作后此实例的值应与在组合数据集上应用单个统计数据时的值相同。
- 指定者:
-
aggregate在接口中AggregatableStatistic<Sum> - 参数:
-
other- 要聚合到此实例中的实例
-
evaluate
指定输入数组的指定部分的总和,如果指定的子数组为空,则返回0。- 指定者:
-
evaluate在接口中MathArrays.Function - 指定者:
-
evaluate在接口中StorelessUnivariateStatistic - 指定者:
-
evaluate在接口中UnivariateStatistic - 参数:
-
values- 输入数组 -
begin- 要包含的第一个数组元素的索引 -
length- 要包含的元素数 - 返回:
- 值的总和,如果长度=0,则为0
- 抛出:
-
MathIllegalArgumentException- 如果数组为null或数组索引参数无效 - 另请参阅:
-
evaluate
public double evaluate(double[] values, double[] weights, int begin, int length) throws MathIllegalArgumentException 指定输入数组的指定部分的加权和,如果指定的子数组为空,则返回0。如果以下任一情况为真,则抛出
MathIllegalArgumentException:- 值数组为null
- 权重数组为null
- 权重数组的长度与值数组的长度不同
- 权重数组包含一个或多个无限值
- 权重数组包含一个或多个NaN值
- 权重数组包含负值
- 开始和长度参数未确定有效数组
使用以下公式,
加权和 = Σ(values[i] * weights[i])
- 指定者:
-
evaluate在接口中WeightedEvaluation - 参数:
-
values- 输入数组 -
weights- 权重数组 -
begin- 要包括的第一个数组元素的索引 -
length- 要包括的元素数量 - 返回:
- 值的总和,如果长度为0则返回0
- 抛出:
-
MathIllegalArgumentException- 如果参数无效
-
copy
返回具有相同内部状态的统计量的副本。- 指定者:
-
copy在接口中StorelessUnivariateStatistic - 指定者:
-
copy在接口中UnivariateStatistic - 指定者:
-
copy在类中AbstractStorelessUnivariateStatistic - 返回:
- 统计量的副本
-