|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectFacemorph.GMM
public class GMM
A Gaussian mixture model
| Constructor Summary | |
|---|---|
GMM(int count)
Constructs a GMM of count clusters |
|
| Method Summary | |
|---|---|
static double[] |
append(double[] s_frame,
double[] a_frame)
Method to concatanate two arrays |
static java.util.Vector |
appendVectors(java.util.Vector v1,
java.util.Vector v2)
Method to concatanate each array of v2 onto the corresponding array of v1 |
void |
copy(GMM gmm)
Copy the given GMM |
static java.util.Vector |
createDynamics(java.util.Vector samples)
Creates estimates for the dynamic coefficents by concatenating each frame with the next |
static java.util.Vector |
createDynamics2(java.util.Vector samples)
Estimates the derivative of the appearance |
void |
display()
Displays the GMM on the console |
java.util.Vector |
EM(java.util.Vector samples)
Perform the EM algorithm to build a GMM on a number of samples |
void |
EMcluster(int iter,
java.util.Vector samples)
An experimental EM clustering algorithm |
java.util.Vector |
EMcluster(java.util.Vector samples)
Attempt at automatically deciding on the number of cluster (doesn't really work) |
Gaussian |
getCluster(int i)
Get the ith cluster |
int |
getCount()
Gte the number of clusters |
double[] |
getRandomSample(java.util.Random rand)
sample from one Gaussian in cluster selected according to its weight |
double |
getWeight(int i)
Gets the weight of the ith cluster |
void |
initialiseAtSamples(java.util.Vector samples)
Initialise this GMM to have one Gaussian centered on each sample with equal probability |
static void |
main(java.lang.String[] args)
Tests of GMM class |
double |
maxProbabilty()
|
void |
merge(java.util.Vector sampleWeights)
Attempt at merging clusters |
void |
normalise()
Forces the sum of weights to equal 1.0 |
static void |
normalise(double[] vals)
Forces the sum of weights to equal 1.0 |
static void |
normaliseSampleWeights(java.util.Vector sampleWeights)
Normalise the sample weights to have sum of 1 |
static void |
normaliseSampleWeights2(java.util.Vector sampleWeights)
Normalise the sample weights so that the most likely Gaussian has weight 1 and all the rest have weight zero |
double |
prob_sample_given_GMM(java.util.Vector sample)
Calculates the probability of a set of samples |
double |
probability(double[] sample)
Calculates the probability of the sample given |
void |
prune(double threshold)
Remove clusters with a weighting less than threshold |
void |
random(java.util.Random rand,
Gaussian gauss)
Initialises a bunch of random centres |
static int[] |
rank(double[] vec)
Finds the ordering of a set of values |
static void |
rank(double[] vec,
int[] order,
int p,
int l)
Find the ordering of a vector |
void |
read(java.io.DataInputStream in)
Read from a DataInputStream |
void |
read(java.io.StreamTokenizer st)
Read from a StreamTokenizer |
void |
read(java.lang.String filename)
Read this GMM from a file |
static java.util.Vector |
readMFCC(java.io.DataInputStream in)
Read Mel-Frequency Cepstral Coefficients (MFCC) for audio analysis |
static java.util.Vector |
readMFCC(java.io.StreamTokenizer st)
Reads an MFCC file with most of the header stripped out |
static java.util.Vector |
readMFCC(java.lang.String filename)
Read Mel-Frequency Cepstral Coefficients (MFCC) for audio analysis |
static java.util.Vector |
readVectors(java.io.DataInputStream in)
Reads data vectors from an input stream |
static java.util.Vector |
readVectors(java.io.StreamTokenizer st)
Reads vectors using a StreamTokenizer |
static java.util.Vector |
readVectors(java.lang.String filename)
Reads a list of data vecors from a file |
void |
reestimate(java.util.Vector samples,
java.util.Vector sampleWeights)
Rebuild the GMM using the cluster weight for each sample |
static java.util.Vector |
resampleVectors(java.util.Vector v,
int N)
Change the length of a 1D array using bi-linear interpolation |
void |
set(int i,
Gaussian g,
double w)
sets the covariance, mean and weight of cluster i |
GMM |
slice(double[] sample)
Makes a new GMM as sum of slices through Gaussians |
void |
weightSamples(java.util.Vector samples,
java.util.Vector sampleWeights)
Calculate the probability of each sample belonging to each cluster |
void |
write(java.io.PrintStream out)
Write this GMM to a printstream |
void |
write(java.lang.String filename)
Write a this GMM to a file named filename |
static void |
writeVectors(java.util.Vector samples,
java.io.PrintStream out)
Write an array of vectors to a PrintStream |
static void |
writeVectors(java.util.Vector samples,
java.lang.String filename)
Writes vectors to the file named |
static void |
zeroSampleWeights(java.util.Vector sampleWeights)
Set all the values in sampleWeights to zeo |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GMM(int count)
count - the number of clusters to use| Method Detail |
|---|
public void set(int i,
Gaussian g,
double w)
i - index of cluster to setg - The Gaussian of the ith clusterw - the weight of the ith clusterpublic Gaussian getCluster(int i)
i - the index of the cluster to get
public double getWeight(int i)
i - The index of the cluster to get
public int getCount()
public void normalise()
public static void normalise(double[] vals)
vals - the values to normalisepublic void write(java.lang.String filename)
filename - the name of the file to write topublic void write(java.io.PrintStream out)
out - The PrintStream to write topublic void read(java.lang.String filename)
filename - the name of the file to read frompublic void read(java.io.DataInputStream in)
in - The DataInputStream to read frompublic void read(java.io.StreamTokenizer st)
st - The StreamTokenizer to read frompublic GMM slice(double[] sample)
sample - the values of the first n axes of this GMM
public void random(java.util.Random rand,
Gaussian gauss)
rand - a Random number generatorgauss - a Gaussian with the distribution of the samplepublic java.util.Vector EM(java.util.Vector samples)
samples - the vector of samples to fit a GMM to
public static void zeroSampleWeights(java.util.Vector sampleWeights)
sampleWeights - the sampleWeights to zeropublic static void normaliseSampleWeights(java.util.Vector sampleWeights)
sampleWeights - the set of sample weights to normalsiepublic static void normaliseSampleWeights2(java.util.Vector sampleWeights)
sampleWeights - The sample weights to normalise
public void weightSamples(java.util.Vector samples,
java.util.Vector sampleWeights)
samples - the samples to analysesampleWeights - the probability of each cluster for each sample
public void reestimate(java.util.Vector samples,
java.util.Vector sampleWeights)
samples - The samples to put into the GMMsampleWeights - The probability of each sample with respect to each Gaussianpublic void initialiseAtSamples(java.util.Vector samples)
samples - the sample to usepublic java.util.Vector EMcluster(java.util.Vector samples)
samples - the sample to build this GMM for
public void merge(java.util.Vector sampleWeights)
sampleWeights - the weight of each samplepublic static int[] rank(double[] vec)
vec - the vector of values whose ordering we wisht ot ind
public static void rank(double[] vec,
int[] order,
int p,
int l)
vec - the vector to find the order oforder - the order of the vector's valuesp - the start index of the sub array to sortl - the end index of the sub array to sortpublic void prune(double threshold)
threshold - the minimum weight for a clusterpublic double[] getRandomSample(java.util.Random rand)
rand - A Random number generator
public double probability(double[] sample)
sample - The sample to calculate the probability for
public void display()
public static java.util.Vector readVectors(java.lang.String filename)
filename - the name of the file to read from
public static java.util.Vector readVectors(java.io.DataInputStream in)
in - the input stream to read from
public static java.util.Vector readVectors(java.io.StreamTokenizer st)
st - The StreamTokenizer to use to parse tokens
public static void writeVectors(java.util.Vector samples,
java.lang.String filename)
samples - the vectors to writefilename - the name of the file to write them to
public static void writeVectors(java.util.Vector samples,
java.io.PrintStream out)
samples - the samples to writeout - the printstream to write topublic static java.util.Vector readMFCC(java.lang.String filename)
filename - the name of the file to read from
public static java.util.Vector readMFCC(java.io.DataInputStream in)
in - the DataInputStream to read from
public static java.util.Vector readMFCC(java.io.StreamTokenizer st)
st - the StreamTokenizer to read from
public static double[] append(double[] s_frame,
double[] a_frame)
s_frame - The first arraya_frame - the second array
public static java.util.Vector appendVectors(java.util.Vector v1,
java.util.Vector v2)
v1 - The first vector of arraysv2 - the second vector of arrays
public static java.util.Vector resampleVectors(java.util.Vector v,
int N)
v - the vector to resampleN - the desired new length of the vector
public static java.util.Vector createDynamics(java.util.Vector samples)
samples - the speech sample vectors
public static java.util.Vector createDynamics2(java.util.Vector samples)
samples - the samples to find the time deivative of
public double maxProbabilty()
public double prob_sample_given_GMM(java.util.Vector sample)
sample - the samples in a Vector of double[]
public void copy(GMM gmm)
gmm - the gmm to copy
public void EMcluster(int iter,
java.util.Vector samples)
iter - The number of iterations to usesamples - The data samples to build a GMM forpublic static void main(java.lang.String[] args)
args - The command line arguments for main
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||