Package elki.math
Class Mean
- java.lang.Object
-
- elki.math.Mean
-
- Direct Known Subclasses:
MeanVariance
public class Mean extends java.lang.Object
Compute the mean using a numerically stable online algorithm.This class can repeatedly be fed with data using the put() methods, the resulting values for mean can be queried at any time using getMean().
The high-precision function is based on:
P. M. Neely
Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients
Communications of the ACM 9(7), 1966- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getCount()
Get the number of points the average is based on.double
getMean()
Return meanstatic double
highPrecision(double... data)
Static helper function, with extra precisionstatic Mean[]
newArray(int dimensionality)
Create and initialize a new array of MeanVariancestatic double
of(double... data)
Static helper function.void
put(double val)
Add a single value with weight 1.0Mean
put(double[] vals)
Add values with weight 1.0Mean
put(double[] vals, double[] weights)
Add values with weight 1.0void
put(double val, double weight)
Add data with a given weight.void
put(Mean other)
Join the data of another MeanVariance instance.Mean
reset()
Reset the value.java.lang.String
toString()
-
-
-
Constructor Detail
-
Mean
public Mean()
Empty constructor
-
Mean
public Mean(Mean other)
Constructor from other instance- Parameters:
other
- other instance to copy data from.
-
-
Method Detail
-
put
public void put(double val)
Add a single value with weight 1.0- Parameters:
val
- Value
-
put
public void put(double val, double weight)
Add data with a given weight.- Parameters:
val
- dataweight
- weight
-
put
public void put(Mean other)
Join the data of another MeanVariance instance.- Parameters:
other
- Data to join with
-
put
public Mean put(double[] vals)
Add values with weight 1.0- Parameters:
vals
- Values- Returns:
- this
-
put
public Mean put(double[] vals, double[] weights)
Add values with weight 1.0- Parameters:
vals
- Values- Returns:
- this
-
getCount
public double getCount()
Get the number of points the average is based on.- Returns:
- number of data points
-
getMean
public double getMean()
Return mean- Returns:
- mean
-
newArray
public static Mean[] newArray(int dimensionality)
Create and initialize a new array of MeanVariance- Parameters:
dimensionality
- Dimensionality- Returns:
- New and initialized Array
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
reset
public Mean reset()
Reset the value.- Returns:
- this accumulator
-
of
public static double of(double... data)
Static helper function.- Parameters:
data
- Data to compute the mean for.- Returns:
- Mean
-
highPrecision
@Reference(authors="P. M. Neely", title="Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients", booktitle="Communications of the ACM 9(7), 1966", url="https://doi.org/10.1145/365719.365958", bibkey="doi:10.1145/365719.365958") public static double highPrecision(double... data)
Static helper function, with extra precision- Parameters:
data
- Data to compute the mean for.- Returns:
- Mean
-
-