comirva.audio.util.gmm
Class GaussianComponent

java.lang.Object
  extended by comirva.audio.util.gmm.GaussianComponent
All Implemented Interfaces:
XMLSerializable

public final class GaussianComponent
extends Object
implements XMLSerializable

Gaussian Component

Description:

A GaussianMixture consists of several gaussian components, which are modeled by this class. A gaussian component is a n-dimensional gaussian distribution.

See Also:
GaussianMixture

Constructor Summary
GaussianComponent(double componentWeight, Matrix mean, Matrix covariances)
          Creates a gaussian component and checks the component settings for correctness.
 
Method Summary
 double getComponentWeight()
          Computes the components weight or in other words the prior probability of being generated by component i.
 int getDimension()
          Returns the dimension of this n-dimensional gaussian distribution.
 Matrix getMean()
          For testing purpose only.
static double[] getStandardNormalVector(int dimension)
          Returns a vector, whose components are n independent standard normal variates.
 double getWeightedSampleProbability(Matrix x)
          Returns the probability of drawing the given sample from this n-dimensional gaussian distribution weighted with the prior probability of this component.
protected  void maximise(PointList samplePoints, double[] p_ij)
          This method performs the maximization step for this component given the sample points and the estimates p_ij = P(C=i | x_j) for sample j of being generated by this component under the assumption that this sample has been drawn from this GMM.
 double[] nextSample()
          Returns a sample drawn from this n-dimensional gaussian distribution.
 void print()
          Prints some information about this component.
static GaussianComponent readGC(XMLStreamReader parser)
          This method allows to read a gaussian component from a xml input stream as recommended by the XMLSerializable interface.
 void readXML(XMLStreamReader parser)
          Reads the xml representation of an object form the xml input stream.
 void writeXML(XMLStreamWriter writer)
          Writes the xml representation of this object to the xml ouput stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GaussianComponent

public GaussianComponent(double componentWeight,
                         Matrix mean,
                         Matrix covariances)
                  throws IllegalArgumentException
Creates a gaussian component and checks the component settings for correctness.

Parameters:
componentWeight - double the weight of this component
mean - Matrix the mean vector of this component
covariances - Matrix the covariance matrix of this component
Throws:
IllegalArgumentException - thrown if any invalid or incorrect settings were found
Method Detail

getComponentWeight

public double getComponentWeight()
Computes the components weight or in other words the prior probability of being generated by component i.

[P(C = i)]

Returns:
double the components weight

getWeightedSampleProbability

public double getWeightedSampleProbability(Matrix x)
Returns the probability of drawing the given sample from this n-dimensional gaussian distribution weighted with the prior probability of this component.

[p(x | C = i) * P(C = i)]

So this is the probability of the sample under this gaussian distribution, which is only a part of the whole distribution. This is an optimized implementation using the cholesky decomposition.

Parameters:
x - Matrix a sample
Returns:
double the probability of this sample with respect to this distribution weighted with the prior probability of this component.

maximise

protected void maximise(PointList samplePoints,
                        double[] p_ij)
                 throws CovarianceSingularityException
This method performs the maximization step for this component given the sample points and the estimates p_ij = P(C=i | x_j) for sample j of being generated by this component under the assumption that this sample has been drawn from this GMM. So i is fixed to the index of this component.

Parameters:
samplePoints - PointList the sample points
p_ij - double[] the estimates
Throws:
CovarianceSingularityException - thrown if this component got singular during the maximization step

nextSample

public double[] nextSample()
Returns a sample drawn from this n-dimensional gaussian distribution.

Returns:
double[] the sample drawn from this distribution

getStandardNormalVector

public static double[] getStandardNormalVector(int dimension)
Returns a vector, whose components are n independent standard normal variates.

Parameters:
dimension - int the number of components (dimensionality) of the vector
Returns:
double[] a vector, whose components are standard normal variance

getDimension

public int getDimension()
Returns the dimension of this n-dimensional gaussian distribution.

Returns:
int number of dimensions

print

public void print()
Prints some information about this component. This is for debugging purpose only.


getMean

public Matrix getMean()
For testing purpose only.

Returns:
Matrix the mean vector

writeXML

public void writeXML(XMLStreamWriter writer)
              throws IOException,
                     XMLStreamException
Writes the xml representation of this object to the xml ouput stream.

There is the convention, that each call to a writeXML() method results in one xml element in the output stream.

Specified by:
writeXML in interface XMLSerializable
Parameters:
writer - XMLStreamWriter the xml output stream
Throws:
IOException - raised, if there are any io troubles
XMLStreamException - raised, if there are any parsing errors

readXML

public void readXML(XMLStreamReader parser)
             throws IOException,
                    XMLStreamException
Reads the xml representation of an object form the xml input stream.

There is the convention, that readXML() starts parsing by checking the start tag of this object and finishes parsing by checking the end tag. The caller has to ensure, that at method entry the current token is the start tag. After the method call it's the callers responsibility to move from the end tag to the next token.

Specified by:
readXML in interface XMLSerializable
Parameters:
parser - XMLStreamReader the xml input stream
Throws:
IOException - raised, if there are any io troubles
XMLStreamException - raised, if there are any parsing errors

readGC

public static GaussianComponent readGC(XMLStreamReader parser)
                                throws IOException,
                                       XMLStreamException
This method allows to read a gaussian component from a xml input stream as recommended by the XMLSerializable interface.

Parameters:
parser - XMLStreamReader the xml input stream
Returns:
GaussianMixture the GMM read from the xml stream
Throws:
IOException - raised, if there are any io troubles
XMLStreamException - raised, if there are any parsing errors
See Also:
XMLSerializable