Facemorph.pga
Class MultiSpherePGA

java.lang.Object
  extended by Facemorph.pga.MultiSpherePGA

public class MultiSpherePGA
extends java.lang.Object

Principal Geodesic Analysis for hyperspherical data (Experimental, only part completed)


Constructor Summary
MultiSpherePGA()
          Creates a new instance of SpherePGA
MultiSpherePGA(java.util.Vector<double[]> data, int length, double tol)
          Creates a new instance of SpherePGA
 
Method Summary
static void addToAverage(double[] average, double[] b, int n)
          Adds b to the average as the n-th component
 double[] analyse(double[] v)
          Analyses the vector using PGA
static double dotProduct(double[] a, double[] b, int start, int len)
          Calculates the dot product of part of the vectors a and b
 void estimateMean(java.util.Vector<double[]> data, double tol)
          Estimates the intrinsic mean iteratively, until the ||mean||^2
 double[] fold(double[] v)
          Folds the vector v from the tangent space into the manifold
 double[] getMean()
          Return the current estimate of the mean
static double getMean(double[] v, int start, int len)
          Get the mean of a sub-vector
static double length(double[] vec, int start, int len)
          Get the length of a sub-vector
static void main(java.lang.String[] args)
          The main method is used for testing
static void normalise(double[] vec, int vlen)
          Subtract the mean of the sub-vector's coords and normlise length to 1
 void read(java.io.InputStream is)
          Read from the input stream
 double[] reconstruct(double[] v)
          reconstructs from a set of weightings
 void setCount(int c)
          Set the number of the component for the model
static void subtractMean(double[] v, double mean, int start, int len)
          Subtract the mean sub-vector from another sub-vector
 double[] unfold(double[] v)
          Unfolds a sample into the tangent plane
 void write(java.io.Writer w)
          Write to the Writer specified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiSpherePGA

public MultiSpherePGA()
Creates a new instance of SpherePGA


MultiSpherePGA

public MultiSpherePGA(java.util.Vector<double[]> data,
                      int length,
                      double tol)
Creates a new instance of SpherePGA

Parameters:
data - the data vectors to build the SpherePGA from
length - the length of each subvector (assume all the same length)
tol - tolerence factor for intrinsic mean convergence
Method Detail

write

public void write(java.io.Writer w)
           throws java.io.IOException
Write to the Writer specified

Parameters:
w - the Writer to write to
Throws:
java.io.IOException

read

public void read(java.io.InputStream is)
Read from the input stream

Parameters:
is - the input stream to read from

setCount

public void setCount(int c)
Set the number of the component for the model

Parameters:
c -

analyse

public double[] analyse(double[] v)
Analyses the vector using PGA

Parameters:
v - the vector to analyse
Returns:
returns the parameter weightings

reconstruct

public double[] reconstruct(double[] v)
reconstructs from a set of weightings

Parameters:
v - the vector of weights
Returns:
returns the reconstructed component

estimateMean

public void estimateMean(java.util.Vector<double[]> data,
                         double tol)
Estimates the intrinsic mean iteratively, until the ||mean||^2
Parameters:
data - the set of data vectors to calculate the mean from
tol - the tolerance used to indicate convergence

getMean

public double[] getMean()
Return the current estimate of the mean

Returns:
returns the current estimate of the mean

addToAverage

public static void addToAverage(double[] average,
                                double[] b,
                                int n)
Adds b to the average as the n-th component

Parameters:
average - the current (n-sample) estimate of the average
b - the new vector to add
n - the number of samples in the current average estimate

dotProduct

public static double dotProduct(double[] a,
                                double[] b,
                                int start,
                                int len)
Calculates the dot product of part of the vectors a and b

Parameters:
a - vector a
b - vector b
start - the start position to start averaging from
len - the number of components to dot together
Returns:
returns the dot product of the two sub-vectors

unfold

public double[] unfold(double[] v)
Unfolds a sample into the tangent plane

Parameters:
v - the sample to unfold
Returns:
returns the vector unfolded into the tangent plane relative to the current estimate of the mean

fold

public double[] fold(double[] v)
Folds the vector v from the tangent space into the manifold

Parameters:
v - the tangent space vector v to fold
Returns:
returns the equivalent vector in the manifold

length

public static double length(double[] vec,
                            int start,
                            int len)
Get the length of a sub-vector

Parameters:
vec - the vector containing the sub-vector
start - the start position of the sub-vector
len - the length of the sub-vector
Returns:
returns the length of the sub-vector

getMean

public static double getMean(double[] v,
                             int start,
                             int len)
Get the mean of a sub-vector

Parameters:
v - the vector containing the sub-vector
start - the start position of the sub-vector
len - the length of the sub-vector
Returns:
returns the average of the sub-vector components

subtractMean

public static void subtractMean(double[] v,
                                double mean,
                                int start,
                                int len)
Subtract the mean sub-vector from another sub-vector

Parameters:
v - the vector containing the sub-vector
mean - the mean vector
start - the start of the sub-vector
len - the length of the sub-vector

normalise

public static void normalise(double[] vec,
                             int vlen)
Subtract the mean of the sub-vector's coords and normlise length to 1

Parameters:
vec - the vector to normalise, made up from a number of sub-vectors
vlen - the length of each sub-vector

main

public static void main(java.lang.String[] args)
The main method is used for testing

Parameters:
args -