vec_math
Class generalLinearRegression

java.lang.Object
  extended by vec_math.generalLinearRegression

public abstract class generalLinearRegression
extends Object

Abstract base class for all general linear least square fits. Provides methods to derive linear parameters out of the design matrix. Non-abstract subclasses must provide Matrix getBasicFunctions. Out of these the design Matrix is calculated via Aij = Xj(xi)/sig_i, with Xj(xi) the basic functions. Overriding the deriveDesignMatrix(Matrix basicfunction) and just setting the getBasicFunctions() to {} is perfectly legal, because only the design matrix is used in further calculations. The design matrix must have more rows than columns. The normal equations are defined via (A(T)A)a=A(T)b, where A is the design matrix, a is the solution vector and b is the measurement vector: yi/sig_i. The private method invertNormal() expects the design matrix to be set, and calculates the inverse of A(T)A. The diagonal elements of that matrix are the squared standard deviation of the solution vector, which in turn can be found by multiplying A(T)b with the inverse matrix. Lit: Num.Rec. p 671ff.


Field Summary
 double ChiSquare
           
 Matrix Design
           
protected  QuadMatrix Invert
           
 double[] LinFit
           
 Matrix Measure
           
 double Q
           
 double[] si
           
 double[] SigFit
           
 boolean validFit
           
protected  boolean validInvert
           
 boolean validSig
           
 double[] yi
           
 
Constructor Summary
generalLinearRegression()
           
 
Method Summary
 boolean deriveDesignMatrix()
           
 boolean deriveDesignMatrix(Matrix base)
           
 void deriveMeasure()
          Sets the Measure Matrix out of yi,si and Design.
abstract  Matrix getBasicFunctions()
           
 double getChiSquare()
          Returns the chi square of the solution.
 double getQ()
          Returns the 1-p(N-M/2,chi^2/2) value.
 double[] getSigma()
          Returns the vector of the standard deviations of the linear fit parameters.
 double[] getSolution()
          Returns the vector of the solving linear parameters that minimize chi^2 Sets the LinFit array and validFit.
private  void invertNormal()
          Inverts the normal equations (A(T)A), therefore the design matrix must be valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Design

public Matrix Design

Measure

public Matrix Measure

yi

public double[] yi

si

public double[] si

Invert

protected QuadMatrix Invert

validInvert

protected boolean validInvert

LinFit

public double[] LinFit

SigFit

public double[] SigFit

validFit

public boolean validFit

validSig

public boolean validSig

ChiSquare

public double ChiSquare

Q

public double Q
Constructor Detail

generalLinearRegression

public generalLinearRegression()
Method Detail

getBasicFunctions

public abstract Matrix getBasicFunctions()

deriveDesignMatrix

public boolean deriveDesignMatrix()
Returns:
boolean

deriveDesignMatrix

public boolean deriveDesignMatrix(Matrix base)
Parameters:
base -
Returns:
boolean

deriveMeasure

public void deriveMeasure()
Sets the Measure Matrix out of yi,si and Design. If si == null a standard deviation of 1. is adopted for every measurement.


invertNormal

private void invertNormal()
Inverts the normal equations (A(T)A), therefore the design matrix must be valid. If successful, validInvert is set.


getSolution

public double[] getSolution()
Returns the vector of the solving linear parameters that minimize chi^2 Sets the LinFit array and validFit.

Returns:
double

getSigma

public double[] getSigma()
Returns the vector of the standard deviations of the linear fit parameters. Sets the array LinSig and validSig if successful.

Returns:
double

getChiSquare

public double getChiSquare()
Returns the chi square of the solution.

Returns:
double

getQ

public double getQ()
Returns the 1-p(N-M/2,chi^2/2) value.

Returns:
double