IMSL C# Numerical Library

Covariances Class

Computes the sample variance-covariance or correlation matrix.

For a list of all members of this type, see Covariances Members.

System.Object
   Imsl.Stat.Covariances

public class Covariances

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

Class Covariances computes estimates of correlations, covariances, or sums of squares and crossproducts for a data matrix x. Weights and frequencies are allowed but not required.

The means, (corrected) sums of squares, and (corrected) sums of crossproducts are computed using the method of provisional means. Let x_{ki} denote the mean based on i observations for the k-th variable, f_i denote the frequency of the i-th observation, w_i denote the weight of the i-th observations, and c_{jki} denote the sum of crossproducts (or sum of squares if j = k) based on i observations. Then the method of provisional means finds new means and sums of crossproducts as shown in the example below.

The means and crossproducts are initialized as follows:

x_{k0}  = 0.0\,\,\,\,\,for\,\,k = 1,\, 
            \ldots ,\,p

c_{jk0}  = 0.0\,\,\,for\,\,j,\,k = 1,\, 
            \ldots ,\,p

where p denotes the number of variables. Letting x_{k,i+1} denote the k-th variable of observation i + 1, each new observation leads to the following updates for x_{ki} and c_{jki} using the update constant r_{i+1}:

r_{i + 1}  = \frac{{f_{i + 1} w_{i + 1} 
            }}{{\sum\limits_{l = 1}^{i + 1} {f_l w_l } }}

\bar x_{k,\;i + 1}  = \bar x_{ki}  + \left( 
            {x_{k,\;i + 1}  - \bar x_{ki} } \right)r_{i + 1}

c_{jk,\;i + 1}  = c_{jki}  + f_{i + 1} 
            w_{i + 1} \left( {x_{j,\;i + 1}  - \bar x_{ji} } \right)\left( 
            {x_{k,\;i + 1}  - \bar x_{ki} } \right)\left( {1 - r_{i + 1} } 
            \right)

The default value for weights and frequencies is 1. Means and variances are computed based on the valid data for each variable or, if required, based on all the valid data for each pair of variables.

Requirements

Namespace: Imsl.Stat

Assembly: ImslCS (in ImslCS.dll)

See Also

Covariances Members | Imsl.Stat Namespace | Example