Class Mean

  • All Implemented Interfaces:
    Statistic

    public class Mean
    extends Object
    implements Statistic
    The mean of a sample is the sum of all numbers in the sample, divided by the sample size. That is,
    E(X) = Σ (xi) / N
    This implementation supports incremental update of the statistic.

    The R equivalent function is mean.

    • Constructor Detail

      • Mean

        public Mean()
        Construct an empty Mean calculator.
      • Mean

        public Mean​(double[] data)
        Construct a Mean calculator, initialized with a sample.
        Parameters:
        data - a sample
      • Mean

        public Mean​(Mean that)
        Copy constructor.
        Parameters:
        that - a Mean calculator
    • Method Detail

      • addData

        public void addData​(double... data)
        Description copied from interface: Statistic
        Recompute the statistic with more data, incrementally if possible.
        Specified by:
        addData in interface Statistic
        Parameters:
        data - an array of new items
      • value

        public double value()
        Description copied from interface: Statistic
        Get the value of the statistic.
        Specified by:
        value in interface Statistic
        Returns:
        the statistic
      • N

        public long N()
        Description copied from interface: Statistic
        Get the size of the sample.
        Specified by:
        N in interface Statistic
        Returns:
        the sample size