$n$個のデータ$x_i$があるとします。
平均
データ$x_i$の平均$\bar{x}$は、次のように計算できます。
$\displaystyle \bar{x} = \dfrac{1}{n} \sum_{i=1}^n x_i$
分散
データ$x_i$の分散$s_x^2$は、次のように計算できます。
$\displaystyle s_x^2 = \dfrac{1}{n} \sum_{i=1}^n (x_i \; – \; \bar{x})^2$
なお、この分散について、平方根をもったものは、標準偏差$s_x$となります。
$\displaystyle s_x = \sqrt{\dfrac{\displaystyle \sum_{i=1}^n (x_i \; – \; \bar{x})^2}{n}}$
相関係数
2つのデータ$x_i$、$y_i$があるとき、相関係数$r$は、次のように計算できます。
$\displaystyle r = \dfrac{\displaystyle \sum_{i=1}^n (x_i \; – \; \bar{x})(y_i \; – \; \bar{y})}{\displaystyle \sqrt{\sum_{i=1}^n (x_i \; – \; \bar{x})^2} \sqrt{\sum_{i=1}^n (y_i \; – \; \bar{y})^2}}$
なお、分散の式を使うと、次のようにも表すことができます。
$\displaystyle r = \dfrac{\displaystyle \sum_{i=1}^n (x_i \; – \; \bar{x})(y_i \; – \; \bar{y})}{n\, s_x \, s_y}$