gov.sandia.cognition.statistics.distribution
Class LinearMixtureModel<DataType,DistributionType extends Distribution<DataType>>

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<DataType,DistributionType>
Type Parameters:
DataType - Type of data in this mixture model
DistributionType - The type of the internal distributions inside the mixture.
All Implemented Interfaces:
Distribution<DataType>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
MultivariateMixtureDensityModel, ScalarMixtureDensityModel

@PublicationReference(author="Wikipedia",
                      title="Mixture Model",
                      type=WebPage,
                      year=2009,
                      url="http://en.wikipedia.org/wiki/Mixture_model")
public abstract class LinearMixtureModel<DataType,DistributionType extends Distribution<DataType>>
extends AbstractDistribution<DataType>

A linear mixture of RandomVariables, with a prior probability distribution. The posterior pdf is: p(x|this) = \sum_{y\in this} p(x|y,this)P(y|this), where p(x|y,this) is the pdf of the underlying RandomVariable, and P(y|this) is the prior probability of RandomVariable y in this.

Since:
1.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Field Summary
protected  ArrayList<? extends DistributionType> distributions
          Underlying distributions from which we sample
protected  double[] priorWeights
          Weights proportionate by which the distributions are sampled
 
Constructor Summary
LinearMixtureModel(Collection<? extends DistributionType> distributions)
          Creates a new instance of LinearMixtureModel
LinearMixtureModel(Collection<? extends DistributionType> distributions, double[] priorWeights)
          Creates a new instance of LinearMixtureModel
 
Method Summary
 LinearMixtureModel<DataType,DistributionType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 int getDistributionCount()
          Gets the number of distributions in the model
 ArrayList<? extends DistributionType> getDistributions()
          Getter for distributions
 double[] getPriorWeights()
          Getter for priorWeights
 double getPriorWeightSum()
          Computes the sum of the prior weights
 DataType sample(Random random)
          Draws a single random sample from the distribution.
 ArrayList<DataType> sample(Random random, int numSamples)
          Draws multiple random samples from the distribution.
 void setDistributions(ArrayList<? extends DistributionType> distributions)
          Setter for distributions
 void setPriorWeights(double[] priorWeights)
          Getter for priorWeights
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

distributions

protected ArrayList<? extends DistributionType extends Distribution<DataType>> distributions
Underlying distributions from which we sample


priorWeights

protected double[] priorWeights
Weights proportionate by which the distributions are sampled

Constructor Detail

LinearMixtureModel

public LinearMixtureModel(Collection<? extends DistributionType> distributions)
Creates a new instance of LinearMixtureModel

Parameters:
distributions - Underlying distributions from which we sample

LinearMixtureModel

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

Parameters:
distributions - Underlying distributions from which we sample
priorWeights - Weights proportionate by which the distributions are sampled
Method Detail

clone

public LinearMixtureModel<DataType,DistributionType> 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 AbstractCloneableSerializable
Returns:
A clone of this object.

toString

public String toString()
Overrides:
toString in class Object

getDistributions

public ArrayList<? extends DistributionType> getDistributions()
Getter for distributions

Returns:
Underlying distributions from which we sample

setDistributions

public void setDistributions(ArrayList<? extends DistributionType> distributions)
Setter for distributions

Parameters:
distributions - Underlying distributions from which we sample

getDistributionCount

public int getDistributionCount()
Gets the number of distributions in the model

Returns:
Number of distributions in the model

sample

public DataType sample(Random random)
Description copied from interface: Distribution
Draws a single random sample from the distribution.

Specified by:
sample in interface Distribution<DataType>
Overrides:
sample in class AbstractDistribution<DataType>
Parameters:
random - Random-number generator to use in order to generate random numbers.
Returns:
Sample drawn according to this distribution.

sample

public ArrayList<DataType> sample(Random random,
                                  int numSamples)
Description copied from interface: Distribution
Draws multiple random samples from the distribution. It is generally more efficient to use this multiple-sample method than multiple calls of the single-sample method. (But not always.)

Parameters:
random - Random-number generator to use in order to generate random numbers.
numSamples - Number of samples to draw from the distribution.
Returns:
Samples drawn according to this distribution.

getPriorWeights

public double[] getPriorWeights()
Getter for priorWeights

Returns:
Weights proportionate by which the distributions are sampled

setPriorWeights

public void setPriorWeights(double[] priorWeights)
Getter for priorWeights

Parameters:
priorWeights - Weights proportionate by which the distributions are sampled

getPriorWeightSum

public double getPriorWeightSum()
Computes the sum of the prior weights

Returns:
Sum of the prior weights