gov.sandia.cognition.statistics.distribution
Class UnivariateGaussian.SufficientStatistic

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.statistics.AbstractSufficientStatistic<Double,UnivariateGaussian>
          extended by gov.sandia.cognition.statistics.distribution.UnivariateGaussian.SufficientStatistic
All Implemented Interfaces:
Factory<UnivariateGaussian>, SufficientStatistic<Double,UnivariateGaussian>, CloneableSerializable, Serializable, Cloneable
Enclosing class:
UnivariateGaussian

@PublicationReference(author="Wikipedia",
                      title="Algorithms for calculating variance",
                      year=2011,
                      type=WebPage,
                      url="http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance")
public static class UnivariateGaussian.SufficientStatistic
extends AbstractSufficientStatistic<Double,UnivariateGaussian>

Captures the sufficient statistics of a UnivariateGaussian, which are the values to estimate the mean and variance.

See Also:
Serialized Form

Field Summary
protected  double mean
          The mean of the Gaussian.
protected  double sumSquaredDifferences
          This is the sum-squared differences
 
Fields inherited from class gov.sandia.cognition.statistics.AbstractSufficientStatistic
count
 
Constructor Summary
UnivariateGaussian.SufficientStatistic()
          Creates a new, empty SufficientStatistic.
UnivariateGaussian.SufficientStatistic(double defaultVariance)
          Creates a new SufficientStatistic with the given value to initialize the variance.
 
Method Summary
 void clear()
          Resets this set of sufficient statistics to its empty state.
 UnivariateGaussian.SufficientStatistic clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 UnivariateGaussian.PDF create()
          Creates a new instance of an object.
 void create(UnivariateGaussian distribution)
          Modifies the given distribution with the parameters indicated by the sufficient statistics
 double getMean()
          Gets the mean of the Gaussian.
 double getSumSquaredDifferences()
          Gets the sum of squared differences from the mean.
 double getVariance()
          Gets the variance of the Gaussian.
 UnivariateGaussian.SufficientStatistic plus(UnivariateGaussian.SufficientStatistic other)
          Adds this set of sufficient statistics to another and returns the combined sufficient statistics.
 void plusEquals(UnivariateGaussian.SufficientStatistic other)
          Adds another sufficient statistic to this one.
 void update(double value)
          Adds a value to the sufficient statistics for the Gaussian.
 void update(Double value)
          Updates the sufficient statistics from the given value
 
Methods inherited from class gov.sandia.cognition.statistics.AbstractSufficientStatistic
getCount, setCount, update
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mean

protected double mean
The mean of the Gaussian.


sumSquaredDifferences

protected double sumSquaredDifferences
This is the sum-squared differences

Constructor Detail

UnivariateGaussian.SufficientStatistic

public UnivariateGaussian.SufficientStatistic()
Creates a new, empty SufficientStatistic.


UnivariateGaussian.SufficientStatistic

public UnivariateGaussian.SufficientStatistic(double defaultVariance)
Creates a new SufficientStatistic with the given value to initialize the variance. This is the initial value for the sum of squared differences. As the number of elements becomes larger, the impact of the default variance will decrease.

Parameters:
defaultVariance - The default variance to use. Must be greater than or equal to zero.
Method Detail

clone

public UnivariateGaussian.SufficientStatistic clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractSufficientStatistic<Double,UnivariateGaussian>
Returns:
A clone of this object.

clear

public void clear()
Resets this set of sufficient statistics to its empty state.


create

public UnivariateGaussian.PDF create()
Description copied from interface: Factory
Creates a new instance of an object.

Returns:
A newly created object.

create

public void create(UnivariateGaussian distribution)
Description copied from interface: SufficientStatistic
Modifies the given distribution with the parameters indicated by the sufficient statistics

Parameters:
distribution - Distribution to modify by side effect

update

public void update(Double value)
Description copied from interface: SufficientStatistic
Updates the sufficient statistics from the given value

Parameters:
value - Value to update the sufficient statistics

update

public void update(double value)
Adds a value to the sufficient statistics for the Gaussian.

Parameters:
value - The value to add.

plus

public UnivariateGaussian.SufficientStatistic plus(UnivariateGaussian.SufficientStatistic other)
Adds this set of sufficient statistics to another and returns the combined sufficient statistics.

Parameters:
other - The other set of sufficient statistics.
Returns:
A combined set of sufficient statistics. The result is the same as if all of the elements added to this and other were added to one sufficient statistic.

plusEquals

public void plusEquals(UnivariateGaussian.SufficientStatistic other)
Adds another sufficient statistic to this one. Makes this one as if all the items added to the other sufficient statistics were added to this one.

Parameters:
other - The other set of sufficient statistics.

getMean

public double getMean()
Gets the mean of the Gaussian.

Returns:
The mean.

getVariance

public double getVariance()
Gets the variance of the Gaussian.

Returns:
The variance.

getSumSquaredDifferences

public double getSumSquaredDifferences()
Gets the sum of squared differences from the mean. Used to compute the variance.

Returns:
The sum of squared differences from the mean.