us.ihmc.utilities.math.functionApproximation
Class LinearRegression

java.lang.Object
  extended by us.ihmc.utilities.math.functionApproximation.LinearRegression

public class LinearRegression
extends java.lang.Object

Title:LinearRegression

Description: A helper class to solve linear regression problems. The client provides a set of input vectors x_{1...p} and a set of corresponding output values y_{1...p}, this calculates the weights to multiply the input vector x by to approximate y. The number of data points provided, p, must be greater than n, the number of dimensions in x. This algorithm makes all the assumptions needed when using the least squares (Gauss-Markov) method. Like all good things, this was found on wikipedia. Note that to have an offset the client should augment the input vectors with a constant term.

Copyright: Copyright (c) 2007

Company: IHMC

Version:
1.0
Author:
jrebula

Field Summary
static boolean VERBOSE
           
 
Constructor Summary
LinearRegression(java.util.ArrayList<double[]> inputs, java.util.ArrayList<java.lang.Double> outputs)
          Creates a linear regression problem with the given data set.
LinearRegression(double[][] inputs, double[] outputs)
          Creates a linear regression problem with the given data set.
LinearRegression(com.mathworks.jama.Matrix inputData, com.mathworks.jama.Matrix outputData)
          Creates a linear regression problem with the given data set.
 
Method Summary
 com.mathworks.jama.Matrix getCoefficientVectorAsMatrix()
           
 double getSquaredError()
           
 void packCoefficientVector(double[] coefficientVector)
           
 boolean solve()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERBOSE

public static boolean VERBOSE
Constructor Detail

LinearRegression

public LinearRegression(com.mathworks.jama.Matrix inputData,
                        com.mathworks.jama.Matrix outputData)
Creates a linear regression problem with the given data set.

Parameters:
inputData - Matrix nxp matrix of input vectors
outputData - Matrix 1xp vector of output values

LinearRegression

public LinearRegression(java.util.ArrayList<double[]> inputs,
                        java.util.ArrayList<java.lang.Double> outputs)
Creates a linear regression problem with the given data set.

Parameters:
inputs - ArrayList p sized list of double arrays, each of length n, representing the input vectors
outputs - ArrayList p sized list of doubles representing the output values

LinearRegression

public LinearRegression(double[][] inputs,
                        double[] outputs)
Creates a linear regression problem with the given data set.

Parameters:
inputs - double[][] the input matrix with dimensions [p][n].
outputs - double[] the array of output values
Method Detail

solve

public boolean solve()

getSquaredError

public double getSquaredError()

getCoefficientVectorAsMatrix

public com.mathworks.jama.Matrix getCoefficientVectorAsMatrix()

packCoefficientVector

public void packCoefficientVector(double[] coefficientVector)