Facemorph.psm
Class DiagonalGaussian

java.lang.Object
  extended by Facemorph.psm.DiagonalGaussian

public class DiagonalGaussian
extends java.lang.Object

DiagonalGaussian model


Constructor Summary
DiagonalGaussian(double[] mean, double[] variance)
          DisagonalGaussian constructor
DiagonalGaussian(int dim)
          DiagonalGaussian constructor
 
Method Summary
 void build(java.util.Vector samples)
          Build from a sample of double[] vectors
 double build(java.util.Vector samples, java.util.Vector<java.lang.Double> sampleWeights)
          Builds the mean and covariance matrix from the samples given
 double build(java.util.Vector samples, java.util.Vector sampleWeights, int index)
          Builds the mean and covariance matrix from the samples given
 double[] getMean()
          Get the mean vector
 double[] getRandomSample(java.util.Random rand)
          Gets a random vector sampled from this Gaussian distribution
 double probability(double[] sample)
          Calculates the probability of a sample vector
 void read(java.io.StreamTokenizer st)
          Read from a StreamTokenizer
 void write(java.io.PrintStream ps)
          Write to a PrintStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiagonalGaussian

public DiagonalGaussian(int dim)
DiagonalGaussian constructor

Parameters:
dim - the dimension of the space

DiagonalGaussian

public DiagonalGaussian(double[] mean,
                        double[] variance)
DisagonalGaussian constructor

Parameters:
mean - the mean position
variance - the variance along each axis
Method Detail

build

public void build(java.util.Vector samples)
Build from a sample of double[] vectors

Parameters:
samples - the samples to build from

build

public double build(java.util.Vector samples,
                    java.util.Vector sampleWeights,
                    int index)
Builds the mean and covariance matrix from the samples given

Parameters:
samples - the samples to build from
sampleWeights - the weights of the samples
index - the index of each element in sampleqweights to use for the weighting
Returns:
returns the sum of sample weights, or zero on an error

build

public double build(java.util.Vector samples,
                    java.util.Vector<java.lang.Double> sampleWeights)
Builds the mean and covariance matrix from the samples given

Parameters:
samples - the samples to build from
sampleWeights - the weights of each sample
Returns:
return the sample of samples weights, or 0 if something goes wrong

probability

public double probability(double[] sample)
                   throws BigMatException
Calculates the probability of a sample vector

Parameters:
sample - the sdample to evaluate
Returns:
returns the probability
Throws:
BigMatException

getRandomSample

public double[] getRandomSample(java.util.Random rand)
Gets a random vector sampled from this Gaussian distribution

Parameters:
rand - a Random number generator
Returns:
return a random sample

getMean

public double[] getMean()
Get the mean vector

Returns:
return teh mean vector

write

public void write(java.io.PrintStream ps)
Write to a PrintStream

Parameters:
ps - the PrintStream to write to

read

public void read(java.io.StreamTokenizer st)
          throws java.io.IOException
Read from a StreamTokenizer

Parameters:
st - the StreamTokenizer to read from
Throws:
java.io.IOException