 - About - Contract - Library - - Books - - - AJGP - - Code - - Courses - - Links - - Media - - Tutorials - People - - David - - - Résumé - - Shannon - Portfolio - Update # The Cross-productis the Dot Product

2005-06-01

## Abstract

This tutorial shows the relationship between the Pearson product-moment correlation coefficient from statistics and the dot product from linear algebra.

## Motivation

The standard deviation seems a bit odd when you compare it to the more intuitive average absolute deviation. Worse, the standard deviation stretches to reach out to highly deviant scores which you might consider throwing out of your data anyway. One wonders why the standard deviation formula is used at all when it seems somewhat arbitrary.

If you record sample data for two variables such as x and y and then compute the Pearson product-moment correlation coefficient, it will always fall between -1 and +1. This bit of magic occurs because the correlation coefficient is the average cross-product of z scores and the z scores are scaled by those stretchy standard deviations. This is a clue that the standard deviation is not as arbitrary as it first seems.

Bear in mind that the cross-product of z scores is not the same as the cross product of two three-dimensional vectors. The cross-product of z scores comes from statistics as used in the correlation coefficient and the other cross product comes from linear algebra as used in computer graphics and physics. It turns out, however, that the cross-product of statistics is the dot product of linear algebra.

The formula for the standard deviation looks almost like the length of multidimensional vector centered at the mean. Could the standard deviation be a way of converting a data vector into a normalized unit vector? Yes, if you note that the square root of the number of samples n in the denominator of the standard deviation cancels out when you compute the correlation coefficient. You then have the projection of one n-dimensional unit vector onto another. This is the cosine of the angle between them and this always falls between -1 and +1.

## Proof

1. Mean

${m}_{x}=\left(\underset{i=1}{\overset{n}{\Sigma }}{x}_{i}\right)/n$

2. Variance

${\sigma }_{x}^{2}=\left(\underset{i=1}{\overset{n}{\Sigma }}{\left[{x}_{i}-{m}_{x}\right]}^{2}\right)/n$

3. Standard Deviation

${\sigma }_{x}=\sqrt{{\sigma }_{x}^{2}}$

4. Z Score

${z}_{\mathrm{x,i}}=\left({x}_{i}-{m}_{x}\right)/{\sigma }_{x}$

5. Correlation Coefficient

$r=\frac{\underset{i=1}{\overset{n}{\Sigma }}\left[{z}_{\mathrm{x,i}}*{z}_{\mathrm{y,i}}\right]}{n}$

6. Average Cross-product

$r=\frac{\underset{i=1}{\overset{n}{\Sigma }}\left[\left(\frac{{x}_{i}-{m}_{x}}{{\sigma }_{x}}\right)*\left(\frac{{y}_{i}-{m}_{y}}{{\sigma }_{y}}\right)\right]}{n}$

7. Move the constants

$r=\frac{1}{{\sigma }_{x}*{\sigma }_{y}*n}*\underset{i=1}{\overset{n}{\Sigma }}\left[\left({x}_{i}-{m}_{x}\right)*\left({y}_{i}-{m}_{y}\right)\right]$

8. Dot Product

9. Standard Deviation in Terms of Norm

10. The n cancels out

11. Projection of Unit Vectors

12. Proportionate Reduction in Error

${r}^{2}={\mathrm{cos}}^{2}\left(\theta \right)=1-{\mathrm{sin}}^{2}\left(\theta \right)$

13. Perpendicular to Projection

$\mathrm{sin}\left(\theta \right)$  