covar
- covar(fs1, fs2)
Computes the point-wise covariance of
fs1
andfs2
.- Parameters
- Return type
The result is a single field. With N fields in
fs1
andfs2
by denoting the i-th value in the k-th field by \(x_{i}^{k}\) and \(y_{i}^{k}\) respectively, the output values can be written as:\[z_{i} = \frac {1}{N} \sum_{k}^{N}x_{i}^{k}y_{i}^{k} - \frac {1}{N} \sum_{k}^{N}x_{i}^{k} \frac {1}{N} \sum_{k}^{N}y_{i}^{k}\]A missing value in either
fs1
orfs2
will result in a missing value in the corresponding place in the output.Note
The following lines are equivalent although the first one is more efficient:
z = covar(x,y) z = mean(x*y)-mean(x)*mean(y)