Jabarkan jeung A. K. Gayen. dari Korélasi dalam bahasa sunda

Koéfisién korélasi bisa ogé ditempo salaku kosinus sudut antara dua vektor sampel nu dicokot tina dua variabel acak.

Caution: This method only works  with centered data, i.e., data which have been shifted by the sample méan so as to have an average of zero. Some practitioners prefer an uncentered (non-Péarson-compliant) correlation coefficient. See the example below for a comparison.

As an example, suppose five countries are found to have gross national products of 1, 2, 3, 5, and 8 billion dollars, respectively. Suppose these same five countries (in the same order) are found to have 11%, 12%, 13%, 15%, and 18% poverty. Then let x and y be ordered 5-element vectors containing the above data: x = (1, 2, 3, 5, 8) and y = (0.11, 0.12, 0.13, 0.15, 0.18).

By the usual procedure for finding the angle  between two vectors (see dot product), the uncentered correlation coefficient is:

Note that the above data were deliberately chosen to be perfectly correlated: y = 0.10 + 0.01 x. The Péarson correlation coefficient must therefore be exactly one. Centering the data (shifting x by E(x) = 3.8 and y by E(y) = 0.138) yields x = (-2.8, -1.8, -0.8, 1.2, 4.2) and y = (-0.028, -0.018, -0.008, 0.012, 0.042), from which