statistics
Class MixtureDensity

java.lang.Object
  extended by statistics.MixtureDensity
All Implemented Interfaces:
java.io.Serializable

public class MixtureDensity
extends java.lang.Object
implements java.io.Serializable

A Gaussian mixture density using either diagonal or full covariance matrices.

Author:
sikoried
See Also:
Serialized Form

Field Summary
 Density[] densities
          component densities
 boolean diagonal
           
 int fd
          feature dimension
 int id
          mixture id
 double llh
          log likelihood accumulator
 java.lang.String name
          give it a name if you want...
 int nd
          number of densities
 double score
          score after evaluation (including priors, or course)
static java.lang.String SYNOPSIS
           
 
Constructor Summary
MixtureDensity(int featureDimension, int numberOfDensities, boolean diagonalCovariances)
          Create a new MixtureDensity.
MixtureDensity(MixtureDensity copy)
           
 
Method Summary
 int classify(double[] x, boolean withPriors)
          Return the index of the highest scoring density (without the prior or exponentiation!)
 void clear()
          Set all the elements of the components to zero
 MixtureDensity clone()
          Return a deep copy of this instance
 double evaluate(double[] x)
          Evaluate the GMM
static void main(java.lang.String[] args)
           
 void posteriors(double[] p)
          Normalize the component scores to posteriors (call evaluate first!)
static MixtureDensity readFromFile(java.lang.String file)
           
 double[] superVector(boolean priors, boolean means, boolean variances)
          Generate a super vector for GMM-SVM use.
 java.lang.String toString()
          Return a String representation of the mixture
 boolean usesDiagonalCovariances()
           
 void writeToFile(java.lang.String file)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

densities

public Density[] densities
component densities


diagonal

public boolean diagonal

fd

public int fd
feature dimension


id

public int id
mixture id


llh

public transient double llh
log likelihood accumulator


name

public java.lang.String name
give it a name if you want...


nd

public int nd
number of densities


score

public transient double score
score after evaluation (including priors, or course)


SYNOPSIS

public static final java.lang.String SYNOPSIS
See Also:
Constant Field Values
Constructor Detail

MixtureDensity

public MixtureDensity(int featureDimension,
                      int numberOfDensities,
                      boolean diagonalCovariances)
Create a new MixtureDensity.

Parameters:
featureDimension - feature dimension
numberOfDensities - number of densities
diagonalCovariances -

MixtureDensity

public MixtureDensity(MixtureDensity copy)
Method Detail

classify

public int classify(double[] x,
                    boolean withPriors)
Return the index of the highest scoring density (without the prior or exponentiation!)

Parameters:
x -
Returns:

clear

public void clear()
Set all the elements of the components to zero


clone

public MixtureDensity clone()
Return a deep copy of this instance

Overrides:
clone in class java.lang.Object

evaluate

public double evaluate(double[] x)
Evaluate the GMM

Parameters:
x - feature vector
Returns:
probability of that mixture

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

posteriors

public void posteriors(double[] p)
Normalize the component scores to posteriors (call evaluate first!)

Parameters:
p - container to save the posteriors to

readFromFile

public static MixtureDensity readFromFile(java.lang.String file)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

superVector

public double[] superVector(boolean priors,
                            boolean means,
                            boolean variances)
Generate a super vector for GMM-SVM use. The generated vector contains (in that order) all priors, mean values and variances (if requested).

Parameters:
priors - include prior probabilities
means - include mean vectors
variances - include variances (diagonal covariance)
Returns:
super vector [apr1 apr2 ... mue1 mue2 ... cov1 cov2 ...]

toString

public java.lang.String toString()
Return a String representation of the mixture

Overrides:
toString in class java.lang.Object

usesDiagonalCovariances

public boolean usesDiagonalCovariances()

writeToFile

public void writeToFile(java.lang.String file)
                 throws java.io.IOException
Throws:
java.io.IOException