Some statistical tools used in multivariate analysis
Utility routines used in several other routines
WARNING!!!!!
These routines are designed on the assumption that the input
dataset is arranged as a matrix NxM, with N=samples and M=channels
This functions depend critically on the arrangement of the input
datasets. This order has been chosen due to an easier implementation
of the code:
The datasets are arranged as arrays NxM, where N (rows)
is the number of samples and M (rows in the array)
is the number of channels (spatial grid cells, for instance)
Imported modules


import LinearAlgebra
import Numeric
import pyclimate.pyclimateexcpt
import pyclimate.tools
import sys

Functions


center
congruence
correlationmatrix
covariancematrix
detrend
standardize
totalvariance


center

center ( dataset )
Returns a centered version (mean along first axis removed) of an array


congruence

congruence ( p1, p2 )
Get the congruence coefficient of two spatial patterns
They must be provided as 1dimensional arrays. If several
dimensions are found it returns an array with the congruence
along the first dimension.


correlationmatrix

correlationmatrix ( X, Y )
Compute the (SMode) correlation matrix of two datasets
Exceptions


pex.MVSTLengthException(len( X ), len( Y ) )



covariancematrix

covariancematrix ( X, Y )
Compute the (SMode) covariance matrix of two datasets
Exceptions


pex.MVSTLengthException(len( X ), len( Y ) )



detrend

detrend (
dataset,
tvalues,
order=1,
)
Removes polinomial trends
Given a linear input dataset, detrend it removing a polynomial of order
N of type trend(t)=\sum_{i=0}^N a_i t^i
Arguments:

dataset
 Numpy array with the data to be detrended (along its first
dimension)

tvalues
 Numpy array with the values of the time coordinate. Its
length must be that of the first dimension of
dataset
Optional arguments:

order
 The order of the polinomial to be removed. Defaults to 1 (linear)
The function returns the detrended (LINEAR) dataset and
the parameters of the trend in a tuple.
Of course, when removing a polynomial of the mentioned type, the
mean is also removed !!!


standardize

standardize ( dataset )
Standardized (centered and unit variance) version of an array


totalvariance

totalvariance ( field )
Returns the total variance of an array
Again, variances along the first dimension of the array are calculated
and the variances obtained are added together.

