Facemorph.tensor
Class AutoRegressor

java.lang.Object
  extended by Facemorph.tensor.AutoRegressor

public class AutoRegressor
extends java.lang.Object

Class to implement auto regression


Field Summary
static int AR_BEST
          Best AR
static int AR_MEAN
          Mean AR
static int AR_ZERO
          Zero mean AR
 
Constructor Summary
AutoRegressor()
           
AutoRegressor(java.util.LinkedList<java.util.LinkedList<double[]>> data, int windowSize, int arConstant)
          Method to calculate the regression coefficients
 
Method Summary
static void add(double[] dest, double[] src, double weight)
          Add a weighted amount of src to dest
static double dotProduct(double[] a, double[] b)
          Dot product between two vectors
 double[] predict(java.util.LinkedList<double[]> previous)
          Predict method
 void read(java.io.InputStream dis)
          Read from an InputStream
 boolean read(java.io.StreamTokenizer st)
          Read auto regression data
 java.util.LinkedList<double[]> test(java.util.LinkedList<double[]> original)
          Test method -finds the difference between the prediction and actual for each frame
 java.util.LinkedList<double[]> transform(java.util.LinkedList<double[]> original, AutoRegressor targetAr)
          Transform method
 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
 

Field Detail

AR_ZERO

public static final int AR_ZERO
Zero mean AR

See Also:
Constant Field Values

AR_MEAN

public static final int AR_MEAN
Mean AR

See Also:
Constant Field Values

AR_BEST

public static final int AR_BEST
Best AR

See Also:
Constant Field Values
Constructor Detail

AutoRegressor

public AutoRegressor()

AutoRegressor

public AutoRegressor(java.util.LinkedList<java.util.LinkedList<double[]>> data,
                     int windowSize,
                     int arConstant)
Method to calculate the regression coefficients

Parameters:
data - The list of data vectors in order
windowSize - The size of the window to use in the regression
arConstant - indicates whether to use zero, the mean or the best constant vector
Method Detail

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.InputStream dis)
Read from an InputStream

Parameters:
dis - the InputStream to read from

read

public boolean read(java.io.StreamTokenizer st)
Read auto regression data

Parameters:
st - the StreamTokenizer to read from
Returns:
returns true if read OK

dotProduct

public static double dotProduct(double[] a,
                                double[] b)
Dot product between two vectors

Parameters:
a - the first vector
b - the second vector
Returns:
return the dot product

add

public static void add(double[] dest,
                       double[] src,
                       double weight)
Add a weighted amount of src to dest

Parameters:
dest - the dest vector
src - the src vector
weight - the amount of src to add to dest

predict

public double[] predict(java.util.LinkedList<double[]> previous)
Predict method

Parameters:
previous - set of vectors
Returns:
returns a weighted sum of the previous

transform

public java.util.LinkedList<double[]> transform(java.util.LinkedList<double[]> original,
                                                AutoRegressor targetAr)
Transform method

Parameters:
original - the original vector
targetAr - the auto regression
Returns:
return the transformed data

test

public java.util.LinkedList<double[]> test(java.util.LinkedList<double[]> original)
Test method -finds the difference between the prediction and actual for each frame

Parameters:
original - the original vector
Returns:
return the residual error data