papaya
Class Correlation.Weighted

java.lang.Object
  extended by papaya.Correlation.Weighted
Enclosing class:
Correlation

public static class Correlation.Weighted
extends Object

Contains methods related to computing the correlation and covariance of weighted datasets.


Method Summary
static float[][] corr(float[][] data, float[] weights, boolean unbiased)
          Returns the weighted linear correlation matrix C.
static float corr(float[] data1, float[] data2, float[] weights, boolean unbiased)
          Returns the weighted linear correlation of two data sequences.
static float[][] cov(float[][] data, float[] weights, boolean unbiased)
          Returns the weighted covariance matrix with element S_JK specifying the weighted covariance between column J and column K of the input matrix.
static float cov(float[] data1, float[] data2, float[] weights, boolean unbiased)
          Returns the weighted covariance between two data sequences.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

corr

public static float[][] corr(float[][] data,
                             float[] weights,
                             boolean unbiased)
Returns the weighted linear correlation matrix C. If S is an estimate of the weighted covariance matrix, then element JK of the weighted correlation matrix C is then given by
 C_JK = S_JK / sqrt(S_JJ,unbiasedValue)*sqrt(S_KK,unbiasedValue).
 
See Correlation.cov(float[][],boolean).

Parameters:
data - input matrix each column corresponding to a sample, each row an observation.
weights - the weights to use.
unbiased - set to true to return the unbiased weighted correlation matrix, false to return the biased version.

corr

public static float corr(float[] data1,
                         float[] data2,
                         float[] weights,
                         boolean unbiased)
Returns the weighted linear correlation of two data sequences.

Parameters:
unbiased - set to true to return the unbiased weighted correlation, false to return the biased version.

cov

public static float cov(float[] data1,
                        float[] data2,
                        float[] weights,
                        boolean unbiased)
Returns the weighted covariance between two data sequences.

Parameters:
unbiased - set to true to return the unbiased weighted covariance, false to return the biased version.

cov

public static float[][] cov(float[][] data,
                            float[] weights,
                            boolean unbiased)
Returns the weighted covariance matrix with element S_JK specifying the weighted covariance between column J and column K of the input matrix.

The formula used to compute element S_JK of the unbiased covariance matrix is:

 S_JK = biasCorrection * Sum ( w[i] * ( dataJ[i] - mu_w(dataJ) )*( dataK[i] - mu_w(dataK) ) ) / Sum (w[i])
 
where mu_w corresponds to the weighted mean of the dataset and the biasCorrection term above is
 biasCorrection = ( Sum(w[i]) )^2  / ( ( Sum(w[i]) )^2 - Sum( w[i]^2 )  ).
 
The elements of the biased covariance matrix are computed sans the bias Correction factor.

Reference: Covariance of weighted samples, wikipedia.org.

Parameters:
data - input matrix each column corresponding to a sample, each row an observation.
weights - the weights to use.
unbiased - set to true to return the unbiased weighted covariance matrix, false to return the biased version.


Processing library papaya by Adila Faruk. (C) 2014