Documentation of 'jsat.math.OnLineStatistics' Java class
OnLineStatistics
jsat.math

Class OnLineStatistics

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.function.BiFunction<OnLineStatistics,OnLineStatistics,OnLineStatistics>, java.util.function.BinaryOperator<OnLineStatistics>


    public class OnLineStatistics
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable, java.util.function.BinaryOperator<OnLineStatistics>
    This class provides a means of updating summary statistics as each new data point is added. The data points are not stored, and values are updated with an online algorithm.
    As such, this class has constant memory usage, regardless of how many values are added. But the results may not be as numerically accurate, and can degrade badly given specific data sequences.
    See Also:
    Serialized Form
    • Constructor Detail

      • OnLineStatistics

        public OnLineStatistics()
        Creates a new set of statistical counts with no information
      • OnLineStatistics

        public OnLineStatistics(double n,
                                double mean,
                                double variance,
                                double skew,
                                double kurt)
        Creates a new set of statistical counts with these initial values, and can then be updated in an online fashion
        Parameters:
        n - the total weight of all data points added. This value must be non negative
        mean - the starting mean. If n is zero, this value will be ignored.
        variance - the starting variance. If n is zero, this value will be ignored.
        skew - the starting skewness. If n is zero, this value will be ignored.
        kurt - the starting kurtosis. If n is zero, this value will be ignored.
        Throws:
        java.lang.ArithmeticException - if n is a negative number
      • OnLineStatistics

        public OnLineStatistics(OnLineStatistics other)
        Copy Constructor
        Parameters:
        other - the version to make a copy of
    • Method Detail

      • add

        public void add(double x)
        Adds a data sample with unit weight to the counts.
        Parameters:
        x - the data value to add
      • add

        public void add(double x,
                        double weight)
        Adds a data sample the the counts with the provided weight of influence.
        Parameters:
        x - the data value to add
        weight - the weight to give the value
        Throws:
        java.lang.ArithmeticException - if a negative weight is given
      • remove

        public void remove(double x,
                           double weight)
        Effectively removes a sample with the given value and weight from the total. Removing values that have not been added may yield results that have no meaning

        NOTE: getSkewness() and getKurtosis() are not currently updated correctly
        Parameters:
        x - the value of the sample
        weight - the weight of the sample
        Throws:
        java.lang.ArithmeticException - if a negative weight is given
      • remove

        public static OnLineStatistics remove(OnLineStatistics A,
                                              OnLineStatistics B)
        Computes a new set of statistics that is the equivalent of having removed all observations in B from A.
        NOTE: removing statistics is not as numerically stable. The values of the 3rd and 4th moments getSkewness() and getKurtosis() will be inaccurate for many inputs. The min and max can not be determined in this setting, and will not be altered.
        Parameters:
        A - the first set of statistics, which must have a larger value for getSumOfWeights() than B
        B - the set of statistics to remove from A.
        Returns:
        a new set of statistics that is the removal of B from A
      • remove

        public void remove(OnLineStatistics B)
        Removes from this set of statistics the observations that where collected in B.
        NOTE: removing statistics is not as numerically stable. The values of the 3rd and 4th moments getSkewness() and getKurtosis() will be inaccurate for many inputs. The min and max can not be determined in this setting, and will not be altered.
        Parameters:
        B - the set of statistics to remove
      • add

        public static OnLineStatistics add(OnLineStatistics A,
                                           OnLineStatistics B)
        Computes a new set of counts that is the sum of the counts from the given distributions.

        NOTE: Adding two statistics is not as numerically stable. If A and B have values of similar size and scale, the values of the 3rd and 4th moments getSkewness() and getKurtosis() will suffer from catastrophic cancellations, and may not be as accurate.
        Parameters:
        A - the first set of statistics
        B - the second set of statistics
        Returns:
        a new set of statistics that is the addition of the two.
      • add

        public void add(OnLineStatistics B)
        Adds to the current statistics all the samples that were collected in B.
        NOTE: Adding two statistics is not as numerically stable. If A and B have values of similar size and scale, the values of the 3rd and 4th moments getSkewness() and getKurtosis() will suffer from catastrophic cancellations, and may not be as accurate.
        Parameters:
        B - the set of statistics to add to this set
      • clone

        public OnLineStatistics clone()
        Overrides:
        clone in class java.lang.Object
      • getSumOfWeights

        public double getSumOfWeights()
        Returns the sum of the weights for all data points added to the statistics. If all weights were 1, then this value is the number of data points added.
        Returns:
        the sum of weights for every point currently contained in the statistics.
      • getMean

        public double getMean()
      • getVarance

        public double getVarance()
        Computes the population variance
        Returns:
        the variance of the data seen
      • getStandardDeviation

        public double getStandardDeviation()
      • getSkewness

        public double getSkewness()
      • getKurtosis

        public double getKurtosis()
      • getMin

        public double getMin()
      • getMax

        public double getMax()

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.