Facemorph.pga
Class SpherePGA

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

public class SpherePGA
extends java.lang.Object

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


Constructor Summary
SpherePGA(java.util.Vector<double[]> data, double tol)
          Creates a new instance of SpherePGA
 
Method Summary
static void addToAverage(double[] average, double[] b, int n)
          Add an (unfolded) sample to the average
 void addToAverage(double[] v, int n)
          Adds a sample to the average
 double[] analyse(double[] v)
          Analyse the vector given this model
 void calculateMean(java.util.Vector<double[]> data)
          Estimate the mean
 void estimateMean(java.util.Vector<double[]> data, double tol)
          Estimate the mean of the dataset on the hypersphere
 double[] fold(double[] v)
          Folds the sample back into the sphere
 double[] getMean()
          Return the current estimate of the mean
static double length(double[] vec)
          Returns the length of the vector
static void main(java.lang.String[] args)
          The main method is used for testing
static void normalise(double[] vec)
          Subtract the mean of the vector's coords and normlise length to 1
 double[] reconstruct(double[] v)
          Reconstruct using this model
 double[] unfold(double[] v)
          Unfolds a sample into the tangent plane
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpherePGA

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

Parameters:
data - the data vectors to build the SpherePGA from
tol - tolerence factor for intrinsic mean convergence
Method Detail

analyse

public double[] analyse(double[] v)
Analyse the vector given this model

Parameters:
v - the vector to analyse
Returns:
returns the model parameters

reconstruct

public double[] reconstruct(double[] v)
Reconstruct using this model

Parameters:
v - the parameter vector
Returns:
returns the spatial vector

calculateMean

public void calculateMean(java.util.Vector<double[]> data)
Estimate the mean

Parameters:
data - The data to use to estimate the mean

estimateMean

public void estimateMean(java.util.Vector<double[]> data,
                         double tol)
Estimate the mean of the dataset on the hypersphere

Parameters:
data - the data samples
tol - the tolerance, a change in the mean below this halts the iteration

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)
Add an (unfolded) sample to the average

Parameters:
average - the (unfolded) average to add to
b - the vector to add
n - the number currently in the average

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 sample back into the sphere

Parameters:
v - the (flattened) vector to fold
Returns:
returns the folded location of the point

length

public static double length(double[] vec)
Returns the length of the vector

Parameters:
vec - the vector to normalise
Returns:
returns the length

addToAverage

public void addToAverage(double[] v,
                         int n)
Adds a sample to the average

Parameters:
v - the sample to add
n - the number of samples previously added to the mean

normalise

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

Parameters:
vec - the vector to normalise

main

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

Parameters:
args -