corr_a
- corr_a(fs1, fs2[, area])
Computes the correlation between
fs1
andfs2
over a weightedarea
.- Parameters
- Return type
number or list
If
area
is not specified the whole field will be used in the calculation. The result is a number for a single field or a list for a multi-fieldFieldset
.With n fields in
fs
by denoting the i-th value in the k-th field by \(x_{i}^{k}\) the output values can be written as:\[ \begin{align}\begin{aligned}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}\\v_{i} = \frac {1}{n} \sum_{k}^{n} (x_{i}^{k})^2 - \frac {1}{n} (\sum_{k}^{n} x_{i}^{k})^2\end{aligned}\end{align} \]Note
The following lines are equivalent although the first one is more efficient:
z = corr_a (x, y) z = covar_a (x, y) / (sqrt(var_a(x)) * sqrt(var_a(y)))