Class SampleMeanVar

java.lang.Object
math.SampleMeanVar

public class SampleMeanVar extends Object
Author:
Federico Granata
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
     
    protected double
     
    protected double
     
    protected double
     
    protected double
     
    protected double
     
    protected double
     
    protected double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of SampleMeanVar
    SampleMeanVar(double[] data)
    Creates a new instance of SampleMeanVar calculating the parameters with the initializing data sequence
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    calcMean(double newValue)
    computes the new mean using a more stable algorithm
    protected void
    calcVar(double newValue)
    computes the new sample variance using a stable algorithm it also computes the mean with the stable algorithm.
    double
    getConfInt(double perc)
    get the actual conf int it is 0 if the variance has not been calculated
    double
    get the greatest value
    double
    get the sample mean
    double
    get the smallest value
    double
    get the sample variance
    void
    initialize a new SampleMeanVar with parameters all zero
    void
    putNewSample(double newValue)
    update the sample mean & variance with the new value it uses stable algorithms
    creates a string with the calculated parameters of the sequence monitored by SampleMeanVar

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • sum

      protected double sum
    • smean

      protected double smean
    • svar

      protected double svar
    • n

      protected double n
    • max

      protected double max
    • min

      protected double min
    • S

      protected double S
    • confInt

      protected double confInt
  • Constructor Details

    • SampleMeanVar

      public SampleMeanVar()
      Creates a new instance of SampleMeanVar
    • SampleMeanVar

      public SampleMeanVar(double[] data)
      Creates a new instance of SampleMeanVar calculating the parameters with the initializing data sequence
      Parameters:
      data - the initial data sequence;
  • Method Details

    • initialize

      public void initialize()
      initialize a new SampleMeanVar with parameters all zero
    • putNewSample

      public void putNewSample(double newValue)
      update the sample mean & variance with the new value it uses stable algorithms
      Parameters:
      newValue -
    • calcMean

      protected void calcMean(double newValue)
      computes the new mean using a more stable algorithm
      Parameters:
      newValue - the new element to be added to the sequence
    • calcVar

      protected void calcVar(double newValue)
      computes the new sample variance using a stable algorithm it also computes the mean with the stable algorithm.
      Parameters:
      newValue - the new element to be added to the sequence
    • getMean

      public double getMean()
      get the sample mean
      Returns:
      the actual sample mean
    • getVar

      public double getVar()
      get the sample variance
      Returns:
      the actual sample variance
    • getMax

      public double getMax()
      get the greatest value
      Returns:
      the actual max value
    • getMin

      public double getMin()
      get the smallest value
      Returns:
      the actual min value
    • getConfInt

      public double getConfInt(double perc)
      get the actual conf int it is 0 if the variance has not been calculated
      Parameters:
      perc - the percentile required
      Returns:
      the confidence interval requested
    • toString

      public String toString()
      creates a string with the calculated parameters of the sequence monitored by SampleMeanVar
      Overrides:
      toString in class Object
      Returns:
      a string