Math for Causal Inference
All simulators

Vector Playground

Drag two vectors and watch the dot product, the angle and the projection; the geometry behind correlation and slopes.

Day 16: Vectors, Matrices & the Dot Product
uv
u
(3, 1)
v
(1, 3)
u · v
6.00
acute angle
angle θ
53.1°
cos θ = 0.600
‖u‖, ‖v‖
3.16, 3.16
projection coefficient
0.600
u·v / v·v (a slope)

With centred data vectors, cos θ is the correlation and the projection coefficient is the regression slope.

Drag the two tips. The dashed orange vector is the projection of u onto v; the dotted segment (the residual) is always perpendicular to v. The dot product is zero exactly when the angle is 90°.