若有 n 個成對的觀察值 (x,y), 則 r 的求法如下:

$\displaystyle r = \frac{S_{xy}}{\sqrt{S_{xx}}\sqrt{S_{yy}}}$
where
$S_{xy}= \sum (x-\overline{x})(y-\overline{y})$ the sum of cross products of the x deviations with the y deviations
$S_{xx}= \sum (x-\overline{x})^2$ the sum of squared deviations of x
$S_{yy}= \sum (y-\overline{y})^2$ the sum of squared deviations of y

Calculate r for the n=4 pairs of observations (2,5), (1,3), (5,6), (0,2)

由上面的公式及下表可以求得相關係數 $\displaystyle r = \frac{S_{xy}}{\sqrt{S_{xx}}\sqrt{S_{yy}}} =
\frac{11}{\sqrt{14}\sqrt{10}}=.930$說明了 (x,y) 有高度的相關性.

$\begin{array}{cccccccc} \hline
&x&y&x-\overline{x}&y-\overline{y}&(x-\overline{...
...\\
&\overline{x}=2&\overline{y}=4&&&S_{xx}&S_{yy}&S_{xy} \\ \hline
\end{array}$

另可用下列方式求得,

$\begin{array}{ccc\vert ccc} \hline
&x&y&x^2&y^2&xy \\ \hline
&2&5&4&25&10 \\
&...
...&16&30&74&43 \\
&\sum x&\sum y&\sum x^2&\sum y^2&\sum xy \\ \hline
\end{array}$

$\displaystyle S_{xx}=\sum x^2 - \frac{(\sum x)^2}{n}$,
$\displaystyle S_{yy}=\sum y^2 - \frac{(\sum y)^2}{n}$,
$\displaystyle S_{xy}=\sum xy - \frac{(\sum x)(\sum y)}{n}$,
$\displaystyle r=\frac{\displaystyle43-\frac{8 \times 16}{4}}
{\displaystyle\sqrt{30-\frac{8^2}{4}}\sqrt{74-\frac{16^2}{4}}} =.930$