gov.sandia.cognition.statistics.distribution
Class ScalarMixtureDensityModel

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.statistics.AbstractDistribution<DataType>
          extended by gov.sandia.cognition.statistics.distribution.LinearMixtureModel<Double,SmoothUnivariateDistribution>
              extended by gov.sandia.cognition.statistics.distribution.ScalarMixtureDensityModel
All Implemented Interfaces:
Vectorizable, ClosedFormComputableDistribution<Double>, ClosedFormDistribution<Double>, ClosedFormUnivariateDistribution<Double>, ComputableDistribution<Double>, Distribution<Double>, DistributionWithMean<Double>, SmoothUnivariateDistribution, UnivariateDistribution<Double>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
ScalarMixtureDensityModel.CDF, ScalarMixtureDensityModel.PDF

@CodeReview(reviewer="Kevin R. Dixon",
            date="2009-10-20",
            changesNeeded=true,
            comments={"Fixed some missing javadoc.","General style fixes.","Added task to figure out a way to avoid storing weights in matrix.","Generally looks good.","Some argument checks need to be more complete"},
            response=@CodeReviewResponse(date="2009-10-20",respondent="Dan Morrow",comments={"added additional test coverage","added more argument checks"},moreChangesNeeded=false))
@PublicationReference(author="Wikipedia",
                      title="Mixture Model",
                      type=WebPage,
                      year=2009,
                      url="http://en.wikipedia.org/wiki/Mixture_density")
public class ScalarMixtureDensityModel
extends LinearMixtureModel<Double,SmoothUnivariateDistribution>
implements SmoothUnivariateDistribution

ScalarMixtureDensityModel (SMDM) implements just that: a scalar mixture density model. There are n distributions which can each be different. There is an n-dimensional vector of prior probabilities which are the probability of selecting each particular distribution. So these prior probabilities must sum to 1.0. To sample from a SMDM is to first select which distribution using the prior probabilities, and then to sample from that distribution to return a sample.

Each distribution must have a mean and variance defined. A mean and variance for the SMDM can be computed. Given an input value, a weighted Z value can be computed for the SMDM distribution.

Author:
jdmorr
See Also:
Serialized Form

Nested Class Summary
static class ScalarMixtureDensityModel.CDF
          CDFof the SMDM
static class ScalarMixtureDensityModel.EMLearner
          An EM learner that estimates a mixture model from data
static class ScalarMixtureDensityModel.PDF
          PDF of the SMDM
 
Field Summary
 
Fields inherited from class gov.sandia.cognition.statistics.distribution.LinearMixtureModel
distributions, priorWeights
 
Constructor Summary
ScalarMixtureDensityModel()
          Creates a new instance of ScalarMixtureDensityModel
ScalarMixtureDensityModel(Collection<? extends SmoothUnivariateDistribution> distributions)
          Creates a new instance of ScalarMixtureDensityModel
ScalarMixtureDensityModel(Collection<? extends SmoothUnivariateDistribution> distributions, double[] priorWeights)
          Creates a new instance of ScalarMixtureDensityModel
ScalarMixtureDensityModel(ScalarMixtureDensityModel other)
          Copy constructor
ScalarMixtureDensityModel(SmoothUnivariateDistribution... distributions)
          Creates a new instance of ScalarMixtureDensityModel
 
Method Summary
 ScalarMixtureDensityModel clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 void convertFromVector(Vector parameters)
          Converts the object from a Vector of parameters.
 Vector convertToVector()
          Converts the object to a vector.
 ScalarMixtureDensityModel.CDF getCDF()
          Gets the CDF of a scalar distribution.
 Double getMaxSupport()
          Gets the minimum support (domain or input) of the distribution.
 Double getMean()
          Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.
 Double getMinSupport()
          Gets the minimum support (domain or input) of the distribution.
 ScalarMixtureDensityModel.PDF getProbabilityFunction()
          Gets the distribution function associated with this Distribution, either the PDF or PMF.
 double getVariance()
          Gets the variance of the distribution.
 
Methods inherited from class gov.sandia.cognition.statistics.distribution.LinearMixtureModel
getDistributionCount, getDistributions, getPriorWeights, getPriorWeightSum, sample, sample, setDistributions, setPriorWeights, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.statistics.Distribution
sample, sample
 

Constructor Detail

ScalarMixtureDensityModel

public ScalarMixtureDensityModel()
Creates a new instance of ScalarMixtureDensityModel


ScalarMixtureDensityModel

public ScalarMixtureDensityModel(SmoothUnivariateDistribution... distributions)
Creates a new instance of ScalarMixtureDensityModel

Parameters:
distributions - Distributions that comprise the SMDM with equal prior weight

ScalarMixtureDensityModel

public ScalarMixtureDensityModel(Collection<? extends SmoothUnivariateDistribution> distributions)
Creates a new instance of ScalarMixtureDensityModel

Parameters:
distributions - Distributions that comprise the SMDM with equal prior weight

ScalarMixtureDensityModel

public ScalarMixtureDensityModel(Collection<? extends SmoothUnivariateDistribution> distributions,
                                 double[] priorWeights)
Creates a new instance of ScalarMixtureDensityModel

Parameters:
distributions - Distributions that comprise the SMDM
priorWeights - Weights proportionate by which the distributions are sampled

ScalarMixtureDensityModel

public ScalarMixtureDensityModel(ScalarMixtureDensityModel other)
Copy constructor

Parameters:
other - SMDM to copy
Method Detail

clone

public ScalarMixtureDensityModel 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 Vectorizable
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class LinearMixtureModel<Double,SmoothUnivariateDistribution>
Returns:
A clone of this object.

convertToVector

public Vector convertToVector()
Description copied from interface: Vectorizable
Converts the object to a vector.

Specified by:
convertToVector in interface Vectorizable
Returns:
The Vector form of the object.

convertFromVector

public void convertFromVector(Vector parameters)
Description copied from interface: Vectorizable
Converts the object from a Vector of parameters.

Specified by:
convertFromVector in interface Vectorizable
Parameters:
parameters - The parameters to incorporate.

getMinSupport

public Double getMinSupport()
Description copied from interface: UnivariateDistribution
Gets the minimum support (domain or input) of the distribution.

Specified by:
getMinSupport in interface UnivariateDistribution<Double>
Returns:
Minimum support.

getMaxSupport

public Double getMaxSupport()
Description copied from interface: UnivariateDistribution
Gets the minimum support (domain or input) of the distribution.

Specified by:
getMaxSupport in interface UnivariateDistribution<Double>
Returns:
Minimum support.

getMean

public Double getMean()
Description copied from interface: DistributionWithMean
Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.

Specified by:
getMean in interface DistributionWithMean<Double>
Specified by:
getMean in interface SmoothUnivariateDistribution
Returns:
Mean of the distribution.

getVariance

@PublicationReference(author="Wikipedia",
                      title="Mixture Model",
                      type=WebPage,
                      year=2009,
                      url="http://en.wikipedia.org/wiki/Mixture_density")
public double getVariance()
Description copied from interface: UnivariateDistribution
Gets the variance of the distribution. This is sometimes called the second central moment by more pedantic people, which is equivalent to the square of the standard deviation.

Specified by:
getVariance in interface UnivariateDistribution<Double>
Returns:
Variance of the distribution.

getProbabilityFunction

public ScalarMixtureDensityModel.PDF getProbabilityFunction()
Description copied from interface: ComputableDistribution
Gets the distribution function associated with this Distribution, either the PDF or PMF.

Specified by:
getProbabilityFunction in interface ComputableDistribution<Double>
Specified by:
getProbabilityFunction in interface SmoothUnivariateDistribution
Returns:
Distribution function associated with this Distribution.

getCDF

public ScalarMixtureDensityModel.CDF getCDF()
Description copied from interface: UnivariateDistribution
Gets the CDF of a scalar distribution.

Specified by:
getCDF in interface ClosedFormUnivariateDistribution<Double>
Specified by:
getCDF in interface SmoothUnivariateDistribution
Specified by:
getCDF in interface UnivariateDistribution<Double>
Returns:
CDF of the scalar distribution.