Gram-Schmidt Orthogonalization
A step-by-step recipe for turning any set of vectors into a set that point at perfect right angles to each other, while spanning exactly the same space — the engine behind cleanly separating overlapping signals.
Prerequisites: Inner Products and Orthogonality, Vector Spaces and Bases
A new trading signal is built, but it turns out to be 70% correlated with the market factor already in the model — some of its apparent predictive power is just repackaged market exposure. Before crediting the new signal with any edge, you need to strip out the part it shares with the market, keeping only what's genuinely new. Gram-Schmidt orthogonalization is the systematic recipe for doing exactly this: given any set of vectors, however overlapping, it produces a new set that point at perfect right angles to each other while still describing the same overall space.
An analogy: peeling off the shared part
Imagine two overlapping circles of light on a wall from two flashlights. To isolate what the second flashlight uniquely contributes, you could measure how much of its light falls exactly where the first flashlight already shines, subtract exactly that overlapping amount, and what's left is the second flashlight's unique contribution — the part with zero overlap with the first. Gram-Schmidt does this arithmetically to vectors: take each new vector, subtract out its "shadow" onto every previous vector, and what remains is orthogonal to all of them by construction.
The mathematics, one symbol at a time
Given vectors , Gram-Schmidt builds an orthogonal set one at a time. Start with . For each subsequent vector, subtract its projection onto every already built:
in words: to build , start with the original and subtract off, one at a time, whatever piece of it points along each already-orthogonalized direction — the fraction is exactly how much of "lies along" (see Inner Products and Orthogonality). What's left, , is guaranteed orthogonal to all of by construction — it's the part of with zero overlap with anything already accounted for. Normalizing each to unit length gives an orthonormal basis, and stacking the process into matrix form is exactly how QR decomposition (see QR Decomposition) is built.
Worked example 1: orthogonalizing two vectors by hand
Let , . Set . Project onto : , , so the projection coefficient is . Then . Check orthogonality: ✓. The pair and now point at exactly 90° to each other, while together they still span the same plane the original pair did.
Worked example 2: stripping the market out of a signal
A new signal's daily values (mean-centered) are , and the market factor's are . Projection coefficient: ; ; coefficient . The market-neutral (orthogonalized) signal is . This is, by construction, completely uncorrelated with the market factor — any predictive power it shows in a backtest can no longer be attributed to simply repackaging market beta.
What this means in practice
Gram-Schmidt is the standard tool for orthogonalizing a candidate signal against known factors before crediting it with independent predictive power (see Orthogonalising a Signal Against Known Factors), and it's the constructive method underlying QR decomposition, which in turn underlies numerically stable least-squares regression.
Gram-Schmidt builds an orthogonal set from any starting set of vectors by, one at a time, subtracting off each vector's projection onto everything already processed — what remains is guaranteed orthogonal to all prior directions, and the resulting set still spans exactly the same space as the original.
The order of vectors matters for interpretation, even though the final space spanned is the same regardless of order. If you orthogonalize a new signal against the market factor first, you get "the signal after removing market exposure." If you instead orthogonalize the market factor against the new signal, you get a different, less meaningful decomposition. Always process the vectors you consider "already explained" (market, known style factors) first, so the leftover piece from your signal of interest is the one that's genuinely orthogonalized against everything you already trust.
Related concepts
Practice in interviews
Further reading
- Strang, Introduction to Linear Algebra, ch. 4
- Trefethen & Bau, Numerical Linear Algebra, lecture 7