gov.sns.tools.statistics
Class MapEstimator

java.lang.Object
  |
  +--gov.sns.tools.statistics.MapEstimator

public class MapEstimator
extends java.lang.Object

y = A x + b where x, y and b are vectors and A is a matrix. x and y are the independent and dependent vectors respectively. A is the estimated matrix map. b is the estimated vector intercept. The estimated map and intercept are defined to be the ones that minimize the scalar product of the vector error in y summed over each sample. That is, we minimize P where: P = Sumi |yi - Aest * xi - best|2 The solution for the estimated matrix, A, is given by: A ( - ) = - b = - A


Field Summary
protected  int _columns
           
protected  double[] _interceptVector
           
protected  double[][] _map
           
protected  int _rows
           
protected  ArrayStatistics _xStats
           
protected  ArrayStatistics _xxStats
           
protected  ArrayStatistics _yStats
           
protected  ArrayStatistics _yxStats
           
protected  boolean interceptNeedsCalc
           
protected  boolean mapNeedsCalc
           
 
Constructor Summary
MapEstimator(int size)
          Creates a new instance of MapEstimator where the number of independent variables equals the number of dependent variables.
MapEstimator(int rows, int columns)
          Create a MapEstimator for a rectangular matrix.
 
Method Summary
 void addSample(double[] x, double[] y)
          Add sample vectors to the population
protected  void calcInterceptEstimate()
          Calculate the estimate of the intercept vector, b, which relates y and x vectors: y = M x + b estimate: b = - M
protected  void calcMapEstimate()
          Calculate the estimate of the map matrix, M, which relates y and x vectors: y = M x + b estimate: M = ( - ) / ( - )
 double[][] getSimpleMap()
          Get the map M where y = M x estimate: M = /
 double[] interceptEstimate()
          accessor to return the intercept estimate
 double[][] mapEstimate()
          accessor to return the map estimate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rows

protected int _rows

_columns

protected int _columns

_map

protected double[][] _map

_interceptVector

protected double[] _interceptVector

_xStats

protected ArrayStatistics _xStats

_yStats

protected ArrayStatistics _yStats

_xxStats

protected ArrayStatistics _xxStats

_yxStats

protected ArrayStatistics _yxStats

mapNeedsCalc

protected boolean mapNeedsCalc

interceptNeedsCalc

protected boolean interceptNeedsCalc
Constructor Detail

MapEstimator

public MapEstimator(int size)
Creates a new instance of MapEstimator where the number of independent variables equals the number of dependent variables.


MapEstimator

public MapEstimator(int rows,
                    int columns)
Create a MapEstimator for a rectangular matrix.

Parameters:
rows - one row for each dependent variable
columns - one column for each independent variable
Method Detail

addSample

public void addSample(double[] x,
                      double[] y)
Add sample vectors to the population


mapEstimate

public double[][] mapEstimate()
accessor to return the map estimate


interceptEstimate

public double[] interceptEstimate()
accessor to return the intercept estimate


getSimpleMap

public double[][] getSimpleMap()
Get the map M where y = M x estimate: M = /


calcMapEstimate

protected void calcMapEstimate()
Calculate the estimate of the map matrix, M, which relates y and x vectors: y = M x + b estimate: M = ( - ) / ( - )


calcInterceptEstimate

protected void calcInterceptEstimate()
Calculate the estimate of the intercept vector, b, which relates y and x vectors: y = M x + b estimate: b = - M