commonSense.math.linear
Class SpecialMatrices

java.lang.Object
  extended bycommonSense.math.linear.SpecialMatrices
All Implemented Interfaces:
VarianceTypes

public class SpecialMatrices
extends java.lang.Object
implements VarianceTypes

This class is the home of several special type matrices.

Sample (co-)variance estimates are used by default, but population (co-) variance estimates can be requested by using the extended methods.

All methods are implemented as class methods and return a Matrix which can be accessed through the methods associated with that.


Field Summary
 
Fields inherited from interface commonSense.stat.VarianceTypes
POPULATION, SAMPLE
 
Method Summary
static Matrix correl(Matrix a)
          Calculates the correlation matrix based on a pre-computed covariance matrix of any type.
static Matrix correl(Matrix a, int type)
          Calculates the correlation matrix based on the input matrix.
static Matrix covar(Matrix a)
          Calculates the standard sample (co-)variance matrix in with n = N - 1 in which N is the number of rows in the matrix.
static Matrix covar(Matrix a, int type)
          Calculates the covariance matrix of the specified type.
static Matrix differenceByColumnMeans(Matrix a)
          Gives the difference matrix with the means calculated by Columns.
static Matrix differenceByRowMeans(Matrix a)
          Gives the difference matrix with the means calculated by row.
static Matrix SSCP(Matrix a)
          Calculates a SSCP (Sum-of-Squares-Cross-Product) matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

SSCP

public static Matrix SSCP(Matrix a)
Calculates a SSCP (Sum-of-Squares-Cross-Product) matrix. The Sum-of-Squares are at the cells at the the main diagonal. The remainig cells contain the Cross-Product calculations.

Parameters:
a - The Matrix of which the SSCP should be calculated
Returns:
A square Matrix with dimensions equal to the smallest of the number of rows and columns.

differenceByColumnMeans

public static Matrix differenceByColumnMeans(Matrix a)
Gives the difference matrix with the means calculated by Columns.

Parameters:
a - The matrix of which the means should be calculated.
Returns:
The difference matrix

differenceByRowMeans

public static Matrix differenceByRowMeans(Matrix a)
Gives the difference matrix with the means calculated by row.

Parameters:
a - The matrix of which the means should be calculated.
Returns:
The difference matrix

covar

public static Matrix covar(Matrix a,
                           int type)
Calculates the covariance matrix of the specified type. When the type is VarianceTypes.SAMPLE it calculates the standard bias free (co-)variance matrix with corresponds with n = N - 1 in which N is the number of rows in the matrix. When the type is VarianceTypes.POPULATION, N is left unchanged (n = N). In general, the number provided for type is subtracted equivalent to n = N - type.

Parameters:
a - The matrix of which the covariance matrix should be calculated.
type - The type of variance that should be calculated, be it sample or population (co-)variances.
Returns:
The covariance matrix
See Also:
VarianceTypes, covar(Matrix)

covar

public static Matrix covar(Matrix a)
Calculates the standard sample (co-)variance matrix in with n = N - 1 in which N is the number of rows in the matrix.

Parameters:
a - The matrix of which the covariance matrix should be calculated.
Returns:
The covariance matrix
See Also:
VarianceTypes, covar(Matrix, int)

correl

public static Matrix correl(Matrix a,
                            int type)
Calculates the correlation matrix based on the input matrix. First it calculates the covariance matrix of the specified type. When the type is VarianceTypes.SAMPLE it calculates the standard bias free (co-)variance matrix with corresponds with n = N - 1 in which N is the number of rows in the matrix. When the type is VarianceTypes.POPULATION, N is left unchanged (n = N). In general, the number provided for type is subtracted equivalent to n = N - type.

Parameters:
a - The matrix of which the correlation should be calculated.
type - The type of variance that should be calculated, be it sample or population (co-)variances.
Returns:
The correlation matrix.
See Also:
VarianceTypes, covar(Matrix), covar(Matrix, int)

correl

public static Matrix correl(Matrix a)
Calculates the correlation matrix based on a pre-computed covariance matrix of any type.

Parameters:
a - The (co-)variance matrix of which the correlation matrix should be calculated.
Returns:
The correlation matrix.
See Also:
covar(Matrix), covar(Matrix, int)


RealJ version 3.5 2001. www.realj.com