Class WeightedMeanVar

java.lang.Object
math.WeightedMeanVar

public class WeightedMeanVar extends Object
Author:
Stefano Omini
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    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
    WeightedMeanVar(double[] data, double[] weight)
    Creates a new instance of SampleMeanVar calculating the parameters with the initializing data sequence
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    calcMeanAndVar(double newValue, double newWeight)
    computes the new sample variance using a stable algorithm it also computes the mean with the stable algorithm.
    double
    get the greatest value
    double
    get the sample mean
    double
    get the smallest value
    double
    get the sample variance
    void
    Creates a new instance of SampleMeanVar
    void
    initialize(double[] data, double[] weight)
    Creates a new instance of SampleMeanVar calculating the parameters with the initializing data sequence
    void
    putNewSample(double newValue, double newWeight)
    update the sample mean & variance with the new value it uses stable algorithms

    Methods inherited from class Object

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

    • mean

      protected double mean
    • var

      protected double var
    • max

      protected double max
    • min

      protected double min
    • expectedValueX2

      protected double expectedValueX2
    • sumWeights

      protected double sumWeights
    • sumSamples

      protected double sumSamples
  • Constructor Details

    • WeightedMeanVar

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

      public WeightedMeanVar(double[] data, double[] weight)
      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()
      Creates a new instance of SampleMeanVar
    • initialize

      public void initialize(double[] data, double[] weight)
      Creates a new instance of SampleMeanVar calculating the parameters with the initializing data sequence
      Parameters:
      data - the initial data sequence;
      weight - the weight
    • putNewSample

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

      protected void calcMeanAndVar(double newValue, double newWeight)
      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
      newWeight - the new weight
    • 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