gov.sandia.cognition.learning.data.feature
Class StandardDistributionNormalizer

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.AbstractScalarFunction<Double>
          extended by gov.sandia.cognition.math.AbstractUnivariateScalarFunction
              extended by gov.sandia.cognition.learning.data.feature.StandardDistributionNormalizer
All Implemented Interfaces:
Evaluator<Double,Double>, ScalarFunction<Double>, UnivariateScalarFunction, CloneableSerializable, Serializable, Cloneable

@CodeReview(reviewer="Kevin R. Dixon",
            date="2009-07-06",
            changesNeeded=false,
            comments={"Made the learning methods take ","Now extends AbstractUnivariateScalarFunction","Cleaned up javadoc"})
public class StandardDistributionNormalizer
extends AbstractUnivariateScalarFunction

The StandardDistributionNormalizer class implements a normalization method where a real value is converted onto a standard distribution. This means that the value is subtracted by the mean and divided by the standard deviation.

f(x) = (x - mean) / (standardDeviation)

Since:
2.0
Author:
Justin Basilico
See Also:
Serialized Form

Nested Class Summary
static class StandardDistributionNormalizer.Learner
          The Learner class implements a BatchLearner object for a StandardDistributionNormalizer.
 
Field Summary
static double DEFAULT_MEAN
          The default mean is 0.0.
static double DEFAULT_VARIANCE
          The default variance is 1.0.
protected  double mean
          The mean of normalization.
protected  double standardDeviation
          The cached value of the standard deviation for normalization.
protected  double variance
          The variance for normalization.
 
Constructor Summary
StandardDistributionNormalizer()
          Creates a new instance of StandardNormalization with a mean of 0.0 and a variance of 1.0.
StandardDistributionNormalizer(double mean, double variance)
          Creates a new instance of StandardDistributionNormalizer with the given mean and variance.
StandardDistributionNormalizer(StandardDistributionNormalizer other)
          Creates a new copy of a StandardDistributionNormalizer.
StandardDistributionNormalizer(UnivariateGaussian gaussian)
          Creates a new instance of StandardDistributionNormalizer from the given Gaussian.
 
Method Summary
 StandardDistributionNormalizer clone()
          Creates a new copy of this StandardDistributionNormalizer.
 double evaluate(double value)
          Normalizes the given double value by subtracting the mean and dividing by the standard deviation (the square root of the variance).
 double getMean()
          Gets the mean.
 double getVariance()
          Gets the variance.
static StandardDistributionNormalizer learn(Collection<? extends Number> values)
          Builds a StandardDistributionNormalizer by computing the mean and variance of the given collection of values.
static StandardDistributionNormalizer learn(Collection<? extends Number> values, double outlierPercent)
          Builds a StandardDistributionNormalizer by computing the mean and variance of the given collection of values.
 void setMean(double mean)
          Sets the mean.
 void setVariance(double variance)
          Sets the variance.
 
Methods inherited from class gov.sandia.cognition.math.AbstractUnivariateScalarFunction
evaluate, evaluateAsDouble
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MEAN

public static final double DEFAULT_MEAN
The default mean is 0.0.

See Also:
Constant Field Values

DEFAULT_VARIANCE

public static final double DEFAULT_VARIANCE
The default variance is 1.0. This means that by default there is no normalization by variance.

See Also:
Constant Field Values

mean

protected double mean
The mean of normalization.


variance

protected double variance
The variance for normalization.


standardDeviation

protected double standardDeviation
The cached value of the standard deviation for normalization.

Constructor Detail

StandardDistributionNormalizer

public StandardDistributionNormalizer()
Creates a new instance of StandardNormalization with a mean of 0.0 and a variance of 1.0.


StandardDistributionNormalizer

public StandardDistributionNormalizer(double mean,
                                      double variance)
Creates a new instance of StandardDistributionNormalizer with the given mean and variance.

Parameters:
mean - The mean.
variance - The variance.

StandardDistributionNormalizer

public StandardDistributionNormalizer(UnivariateGaussian gaussian)
Creates a new instance of StandardDistributionNormalizer from the given Gaussian.

Parameters:
gaussian - The Gaussian to initialize the normalizer with.

StandardDistributionNormalizer

public StandardDistributionNormalizer(StandardDistributionNormalizer other)
Creates a new copy of a StandardDistributionNormalizer.

Parameters:
other - The StandardDistributionNormalizer to copy.
Method Detail

clone

public StandardDistributionNormalizer clone()
Creates a new copy of this StandardDistributionNormalizer.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A new copy of this StandardDistributionNormalizer.

evaluate

public double evaluate(double value)
Normalizes the given double value by subtracting the mean and dividing by the standard deviation (the square root of the variance).

Parameters:
value - The value to normalize.
Returns:
The normalized value.

getMean

public double getMean()
Gets the mean.

Returns:
The mean.

setMean

public void setMean(double mean)
Sets the mean.

Parameters:
mean - The mean.

getVariance

public double getVariance()
Gets the variance.

Returns:
The variance.

setVariance

public void setVariance(double variance)
Sets the variance. It must be greater than 0.0.

Parameters:
variance - The variance.

learn

public static StandardDistributionNormalizer learn(Collection<? extends Number> values)
Builds a StandardDistributionNormalizer by computing the mean and variance of the given collection of values.

Parameters:
values - The values to use to build the normalizer.
Returns:
The StandardDistributionNormalizer created from the mean and variance of the given values.

learn

public static StandardDistributionNormalizer learn(Collection<? extends Number> values,
                                                   double outlierPercent)
Builds a StandardDistributionNormalizer by computing the mean and variance of the given collection of values. It will exclude the given percentage of outliers from the value.

Parameters:
values - The values to use to build the normalizer.
outlierPercent - The percentage of outliers to exclude.
Returns:
The StandardDistributionNormalizer created from the mean and variance of the given values.