A function that can be used in Formulas.
Syntax and semantics

correlation
(u#
, v#
)

compute the correlation between the vectors
u#
and v#
.
Precondition
The vectors u#
and v#
have to have equal numbers of elements.
Definition
If N is the number of elements of both u and v,
m_{u} = (1/N) ∑_{i=1}^{N} u_{i} 
m_{v} = (1/N) ∑_{i=1}^{N} v_{i} 
ssq_{u} = ∑_{i=1}^{N} (u_{i} − m_{u})^{2} 
ssq_{v} = ∑_{i=1}^{N} (v_{i} − m_{v})^{2} 
correlation (u, v) = ∑_{i=1}^{N} (u_{i} − m_{u}) · (v_{i} − m_{v}) / √(ssq_{u} · ssq_{v}) 
Links to this page
© Paul Boersma 2023