org.lcsim.hmatrix
Class HMatrix

java.lang.Object
  extended byorg.lcsim.hmatrix.HMatrix
All Implemented Interfaces:
java.io.Serializable

public class HMatrix
extends java.lang.Object
implements java.io.Serializable

This class allows one to calculate how well a measurement agrees with expectations. The vector of average values and the associated covariance matrix is used to construct the HMatrix. The degree of agreement is calculated as a chi-squared of a measurement vector against the expectations. The covariance matrix is defined as:

Mij =  1

N
N
å
n = 1 
(Ei(n) -

E
 

i 
)(Ej(n) -

E
 

j 
)
The H(essian)Matrix is the inverse of the covariance matrix. The chi-squared is then calculated via
zm º N
å
i,j = 1 
(Ei(m) -

E
 

i 
)Hij (Ej(m) -

E
 

j 
)
Methods to persist the HMatrix are provided in both plain ASCII format and Java serialized format.

Author:
Norman A. Graf
See Also:
Serialized Form

Constructor Summary
HMatrix(int dim, int key, double[] vec, double[][] cov)
          Constructor
 
Method Summary
 double chisquared(double[] dat)
          Calculates the chi-squared for the measurement compared to the expected values and covariances represented by the HMatrix.
static HMatrix read(java.lang.String filename)
          Reads the HMatrix from an ASCII file
static HMatrix readSerialized(java.lang.String filename)
          Reads the HMatrix from a Serialized file
 java.lang.String toString()
          Output stream
 void write(java.lang.String filename, java.lang.String comment)
          Writes out the HMatrix to an ASCII file
 void writeSerialized(java.lang.String filename)
          Writes the HMatrix to a Serialized file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HMatrix

public HMatrix(int dim,
               int key,
               double[] vec,
               double[][] cov)
Constructor

Parameters:
key - the key for indexing this HMatrix
vec - The array of average values for the measurement space.
cov - The inverse of the covariance matrix for the averages.
Method Detail

chisquared

public double chisquared(double[] dat)
Calculates the chi-squared for the measurement compared to the expected values and covariances represented by the HMatrix.

Parameters:
dat - The array of measured values
Returns:
The value of chi-squared.

toString

public java.lang.String toString()
Output stream

Returns:
A String representation of the object.

writeSerialized

public void writeSerialized(java.lang.String filename)
Writes the HMatrix to a Serialized file


readSerialized

public static HMatrix readSerialized(java.lang.String filename)
Reads the HMatrix from a Serialized file


write

public void write(java.lang.String filename,
                  java.lang.String comment)
Writes out the HMatrix to an ASCII file


read

public static HMatrix read(java.lang.String filename)
Reads the HMatrix from an ASCII file