next up previous contents_motif.gif
Next: 7.6.4 Scientific.Functions.LeastSquares Up: 7.6 ScientificPython-2.4.5 Previous: 7.6.2 Scientific.Statistics.mean

7.6.3 Scientific.Statistics.correlation

Description: Computes the correlation coefficient between two 1-dim arrays $a$ and $b$ according to

\begin{displaymath}
c_{ab} = {\langle (a-\bar a) (b-\bar b) \rangle \over
\la...
... (a-\bar a)^2\rangle^{1/2} \langle (b-\bar
b)^2\rangle^{1/2}}
\end{displaymath} (7.1)

Example:

  >>> correlation([1,2,3,4,5],[1,2,3,4,5])
  1.0
  >>> correlation([1,2,3,4,5],[1,2,3,5,5])
  0.96476382123773219
  >>> correlation([1,2,3,4,5],[5,4,3,2,1])
  -1.0


Frank Bertoldi 2005-11-10