A symbol-by-symbol guide with a concrete worked example
The Equation
φ =
|⟨v⟩|
⟨|v|⟩
Each colored symbol is explained below — hover to explore
Reading the notation
This formula is dense with layered brackets. Here's what each layer does.
Bracket decoder — working from inside out
vRaw velocity vector for one agent — has both speed and direction. Example: (3, 4) means moving right 3, up 4.
⟨v⟩Average velocity vector — add all agents' velocity vectors together, divide by agent count. Direction survives if agents are aligned; cancels to near-zero if agents point every which way.
|⟨v⟩|Length of the average vector (numerator). Take the average vector, then measure how long it is. A long vector = agents are aligned. A short vector = directions cancelled out.
|v|Speed of one agent — strip direction, keep only how fast. Example: |(3, 4)| = √(9+16) = 5.
⟨|v|⟩Average speed (denominator) — average the speeds of all agents. This is always positive and acts as a reference scale to normalise the result to [0, 1].
φ = numerator/denominator"How aligned is the flock, scaled by how fast everyone is moving." If all velocities point the same way, the average vector is as long as the average speed → φ = 1.
The order of operations
The numerator and denominator look similar but do something completely different. This is the heart of the formula.
Numerator: |⟨v⟩|
Average the vectors first, then measure the length. Vectors pointing in opposite directions cancel each other out before the length is taken. Chaos → short average vector → small numerator.
Denominator: ⟨|v|⟩
Measure each vector's length first, then average those lengths. Lengths are always positive — they never cancel. This always gives a large-ish number regardless of direction.
Why the ratio reveals alignment
Left: random directions cancel in the average → tiny numerator → φ ≈ 0. Right: aligned directions reinforce → large average vector → φ ≈ 1.
Worked example — five birds
We have 5 birds with the following 2D velocity vectors. We'll compute φ for two scenarios back-to-back.
Scenario A (aligned flock): all birds flying roughly northeast. Scenario B (chaotic flock): same speeds, random directions.
💡 The x-components nearly cancel to zero. The average vector is tiny because directions are fighting each other.
B
Compute ⟨|v|⟩ — speeds don't cancel
|v₁|=5, |v₂|=5, |v₃|=5, |v₄|=5, |v₅|=5
⟨|v|⟩ = 5.00(all happen to be speed 5)
C
Divide to get φ
φ = 1.00 / 5.00 = 0.200
💡 φ = 0.2 — low order. Same agents, same speeds, just pointing in different directions. The formula correctly identifies the chaos.
What φ values mean in practice
0.00.20.50.81.0
← Complete chaos all directions cancelPartial alignmentPerfect order → one shared direction
Scenario A (aligned):
φ = 0.99
Near-perfect flocking order
Scenario B (chaotic):
φ = 0.20
Mostly disordered motion
"Are my agents mostly pointing the same way?
Average their velocity vectors. If alignment is high, that average is long.
Divide by average speed to get a fair 0→1 score."