|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object comirva.audio.util.gmm.GaussianMixture
public final class GaussianMixture
Gaussian Mixture Model
Description
This class implements in combination withGaussianComponent
a
gaussian mixture model. To create a gaussian mixture model you have to
specify means, covariances and the weight for each of the gaussian components.
GaussianMixture
and GaussianComponent do not only model a GMM,
but also support training GMMs using the EM algorithm.KMeansClustering
for initializing the GMM.CovarianceSingularityException
is
thrown. The CovarianceSingularityException
contains a reduced
PointList
. All points belonging to the singular component have
been removed. So after the reduction one can try to rerun the training
Algorithm with the reduced PointList
.
KMeansClustering
,
GaussianComponent
Constructor Summary | |
---|---|
GaussianMixture(double[] componentWeights,
Matrix[] means,
Matrix[] covariances)
This constructor creates a GMM and checks the parameters for plausibility. |
|
GaussianMixture(GaussianComponent[] components)
This constructor creates a GMM and checks the components for compatibility. |
Method Summary | |
---|---|
protected static void |
getBuffer(int nrComponents,
int nrSamplePoints)
This method returns a reference to a buffer for storing estimates of the sample points. |
int |
getDimension()
Returns the number of dimensions of the GMM. |
double |
getLogLikelihood(PointList points)
Returns the log likelihood of the points stored in the pointlist under the assumption the these points where sample from this GMM. |
Matrix |
getMean(int numberOfComponent)
For testing purpose only. |
double |
getProbability(Matrix x)
Returns the probability of a single sample point under the assumption that it was draw from the distribution represented by this GMM. |
double[] |
nextSample()
Draws a sample from this GMM. |
void |
print()
Prints some information about this gaussian component. |
static GaussianMixture |
readGMM(XMLStreamReader parser)
This method allows to read a GMM 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 |
runEM(PointList samplePoints)
Runs the EM algorithm to train this GMM given the sample points in the PointList . |
void |
writeXML(XMLStreamWriter writer)
Writes the xml representation of this object to the xml output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GaussianMixture(double[] componentWeights, Matrix[] means, Matrix[] covariances) throws IllegalArgumentException
componentWeights
- double[] specifies the components weightsmeans
- Matrix[] specifies the components mean vectorscovariances
- Matrix[] specifies the components covariance matrices
IllegalArgumentException
- if any invalid parameter settings are
detected while checking thempublic GaussianMixture(GaussianComponent[] components) throws IllegalArgumentException
components
- GaussianComponent[] an array of gaussian components
IllegalArgumentException
- if the passed components are not
compatibleMethod Detail |
---|
public double getLogLikelihood(PointList points)
points
- PointList list of sample points to estimate the log
likelihood of
public double[] nextSample()
public double getProbability(Matrix x)
x
- Matrix a sample point
public int getDimension()
public void print()
public Matrix getMean(int numberOfComponent)
numberOfComponent
- int the number of the component
protected static void getBuffer(int nrComponents, int nrSamplePoints)
nrComponents
- int the number of components of the gmm to allocate the
buffer fornrSamplePoints
- int the number of sample points of the gmm to
allocate the buffer forpublic static GaussianMixture readGMM(XMLStreamReader parser) throws IOException, XMLStreamException
parser
- XMLStreamReader the xml input stream
IOException
- raised, if there are any io troubles
XMLStreamException
- raised, if there are any parsing errorsXMLSerializable
public void runEM(PointList samplePoints) throws CovarianceSingularityException
PointList
. The EM algorithm runs till either one cannot yield
an improvement of the log likelihood or the number of training iterations
exceeds the number of maximal allowed iterations(MAX_ITERATIONS).
samplePoints
- PointList sample points of the distribution to
approximate by this GMM
CovarianceSingularityException
- thrown if any of the gaussian
components got singularpublic void writeXML(XMLStreamWriter writer) throws IOException, XMLStreamException
writeXML()
method
results in one xml element in the output stream.
writeXML
in interface XMLSerializable
writer
- XMLStreamWriter the xml output stream
IOException
- raised, if there are any io troubles
XMLStreamException
- raised, if there are any parsing errorspublic void readXML(XMLStreamReader parser) throws IOException, XMLStreamException
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.
readXML
in interface XMLSerializable
parser
- XMLStreamReader the xml input stream
IOException
- raised, if there are any io troubles
XMLStreamException
- raised, if there are any parsing errors
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |