Algorithmresearch
Probability hypothesis density filter
Also called PHD filter, GM-PHD filter.
Propagate the first moment of the random finite set of targets, not each track. With linear Gaussian models, constant p_D and p_S and Gaussian mixture birth, the Gaussian mixture form is closed.
- Solves
- Multi-object tracking
- Time
- O(J² (m + 1)² d² + J (m + 1) d³ + J p³) worst · averageO(J (m + 1) (d³ + log(J (m + 1))) + J p³) best
- Space
- O(J (m + 1) d²) extra
- Where
- J = the number of components after the prediction and the birth; d = the dimension of a state; m = the number of measurements; p = the dimension of a measurement with p ≤ d
- Model
- Real RAM
- Properties
- deterministicnot exactnot iterativenot localonline
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Ronald P. S. Mahler, 2003
The probability hypothesis density filter, or PHD filter, tracks an unknown and changing number of targets in clutter without assigning measurements to tracks. It treats the set of all targets as one random object, a random finite set, and it does not propagate the full distribution of that set, which is too large to handle. It propagates only its first moment, the PHD , a density on the state space of one target. The integral of over a region is the expected number of targets in that region. Ronald Mahler derived the prediction and update equations of the PHD in 2003. In general they have no closed form. Vo and Ma showed in 2006 that if the motion and measurement models are linear and Gaussian, the probabilities of detection and survival are constant, and the birth intensity is a Gaussian mixture, then a PHD that is a Gaussian mixture stays a Gaussian mixture. This Gaussian mixture PHD filter, or GM-PHD, is the form on this page. It runs one Kalman filter update per component and measurement, and it keeps the number of components small by pruning and merging.
In plain words
Picture a map of a harbor covered with sand. Where boats are likely to be, the sand is piled high, and the total amount of sand is the number of boats you expect. Each time step, every pile slides along with the current and loses a little sand for boats that may leave. New small piles appear where boats usually enter. Then the radar gives a set of blips. Each pile keeps some of its sand in case its boat was not seen. For each blip, sand is copied to the spot near that blip, in proportion to how well each pile explains it. A blip that no pile explains well is taken as noise and adds little sand. Small piles are swept away, and piles that sit on top of each other are joined. Wherever about one boat's worth of sand is gathered, you report a boat.
The problem
The state of the scene at time is a finite set of target states in , and the measurements form a finite set in . The model is:
- a target with state survives with probability and moves to with density ;
- new targets appear as a Poisson point process with intensity ;
- a target with state is detected with probability , and its measurement has density ;
- the clutter is a Poisson point process with intensity , independent of the targets.
The PHD of given is the density with for every region . The PHD filter computes from and by Mahler's equations, with spawning left out:
The update is exact when the predicted set of targets is a Poisson point process. In general it is an approximation. The output in each frame is the expected number of targets and a set of state estimates.
The algorithm
The PHD is kept as a mixture .
GM-PHD-STEP(the components (w_k, m_k, P_k), the measurements Z, F, Q, H, R, p_S, p_D, κ, the birth components)- 1
for each component: w_k ← p_S w_k; m_k ← F m_k; P_k ← F P_k Fᵀ + Q - 2
append the birth components (w_b, m_b, P_b) - 3
for each component k: η_k ← H m_k; S_k ← H P_k Hᵀ + R; K_k ← P_k Hᵀ S_k⁻¹; P⁺_k ← (I - K_k H) P_k - 4
the missed terms: keep each component with the weight (1 - p_D) w_k - 5
for each z in Z: q_k ← N(z; η_k, S_k); add (p_D w_k q_k / (κ(z) + Σ_l p_D w_l q_l), m_k + K_k (z - η_k), P⁺_k) for each k - 6
drop the components with w_k < T; merge each heaviest component with those within distance U; keep the J_max heaviest - 7
N̂ ← Σ_k w_k; report m_k round(w_k) times for each component with w_k > 0.5
Line L6 follows Vo and Ma. Take the component of largest weight, and collect the components with . Replace them by one component with the sum of their weights, their weighted mean, and the covariance that keeps the second moment. Repeat with the rest. The code uses , and .
Example
One update in one dimension. Two predicted components have weight 1, means 0 and 10, and variance 0.75, so with each has and . Let and , and let the measurements be , and .
| Term | Weight | Mean |
|---|---|---|
| missed, component at 0 | 0 | |
| missed, component at 10 | 10 | |
| 0.375 | ||
| 9.25 | ||
| 3.0 |
The other three terms, each measurement paired with the far component, have weights below . The total weight is , the expected number of targets. The measurement at 4 fits neither component, and the clutter term takes almost all of its share, so it adds only 0.012 targets. After pruning and merging there are three components, with weights 1.069, 1.056 and 0.012 and means 0.34, 9.32 and 3.0, and the filter reports two targets, at 0.34 and 9.32.
A scene in the plane. In the test, three targets with constant velocity are born at frames 0, 0 and 8 near three birth components of weight 0.05, and one of them dies at frame 25. Each is detected with probability 0.95 and noise of standard deviation 0.5, and on average 5 clutter points per frame fall in a window. Over 40 frames, leaving out the three frames after each birth or death, the filter reports the right number of targets, each within 1.5 of a true one, in 28 of 31 frames. Most of the errors come from a missed detection, after which the weight of the target falls to about for one frame.
Correctness
The full proof is in proofs/correctness.md. It shows these facts.
- Theorem: the mixture is closed. If is a Gaussian mixture, lines L1 and L2 give exactly the predicted PHD , and lines L3 to L5 give exactly the updated PHD of the equations above.
- Theorem: the expected number. The weights after line L5 sum to , where and lies in . So each measurement adds less than one expected target, and with no measurements the count is .
- Theorem: merging keeps the moments. A merge in line L6 keeps the total weight, the weighted mean and the weighted second moment of the components it joins.
Pruning and merging change the density, so the filter as a whole is an approximation of the PHD recursion, and the PHD recursion is itself an approximation of the full multi-target Bayes filter. The quality of the state estimates is not proved.
Proof: Why the Gaussian mixture PHD recursion is exact under linear Gaussian models, constant detection and survival probabilities and Gaussian mixture birth, and what pruning and merging keepfull
Notation as on the page. is the Gaussian density with mean and a symmetric positive definite covariance . The matrices and are positive definite, and for every . The PHD recursion is Mahler's prediction and update, as written on the page. This file proves that lines L1 to L5 compute it exactly when the PHD of the previous frame is a Gaussian mixture, and states what lines L6 and L7 keep.
Two facts about Gaussians
Lemma A. .
Proof. Let have the density and let , with independent of and with density . Given , the density of is , so by the law of total probability the left side is the density of . A linear function of the independent Gaussian vectors and is Gaussian, with mean and covariance . This covariance is positive definite because is.
Lemma B. Let , , and . Then
Proof. Let have the density and let , with independent of and with density . The left side is the joint density of . The pair is jointly Gaussian with mean and covariance with the blocks , , and . The matrix is positive definite because is. A joint density is the marginal density of , which is , times the conditional density of given . For a jointly Gaussian pair this conditional density is Gaussian with mean and covariance , by the standard formula for Gaussian conditioning (the Schur complement).
Lemma B is the measurement update of the Kalman filter, with the normalizing constant kept.
Claim 1: the mixture is closed, and lines L1 to L5 are exact
Let . Then the predicted PHD is the mixture of lines L1 and L2, and the updated PHD is the mixture of lines L4 and L5.
Proof. The prediction is linear in , and is a constant, so it can be taken out of the integral:
by Lemma A. This is line L1 for the surviving components and line L2 for the birth components, since the birth intensity is a Gaussian mixture.
Write the predicted PHD as and let , , and be as in line L3, with . The missed term of the update is , which is line L4. For a measurement , because is a constant, Lemma B gives
Each Gaussian on the right integrates to 1, so the integral in the denominator of the update is . Dividing by gives the components of line L5, one for each , with the weights . The update is the sum of the missed term and of these terms over all , which is the mixture that lines L4 and L5 build.
Each hypothesis is used. If depended on , the product would not be a Gaussian in general. If depended on , the same would hold in the prediction. If the models were not linear Gaussian, Lemmas A and B would not apply. If the birth intensity were not a Gaussian mixture, line L2 would not add Gaussian components.
Claim 2: the expected number of targets
The weights after line L5 sum to , where and with . Each lies in .
Proof. The integral of a mixture is the sum of its weights, since each Gaussian integrates to 1. By the property of the PHD on the page, this integral is the expected number of targets. The weights of line L1 sum to , and line L2 adds . Line L4 gives . For one , the weights of line L5 sum to . Since and , . With empty the sum is .
Claim 3: what line L6 keeps
Let a merge join the components into with , and . Then the merged component has the same integral, the same first moment and the same second moment as the part of the mixture it replaces, and is positive definite. Pruning a set of components of total weight changes the PHD by exactly in the norm. The merge loop stops after at most as many rounds as there are components.
Proof. The part has integral , first moment , and second moment . The merged component has the integral , the first moment and the second moment . Expanding,
since . So the second moments agree. The matrix is a positive combination of positive definite matrices and positive semidefinite matrices, so it is positive definite.
Every component is a nonnegative function, so removing components of total weight removes a nonnegative function with integral , and the distance is . The same holds for the cap , which removes the lightest components. In each round of merging, the heaviest component is at distance 0 from itself, so it is in the group and is removed, and the number of remaining components falls by at least one.
Line L7 reads the expected number from the weights by Claim 2. The rule that reports a mean for each weight above 0.5 is a heuristic of Vo and Ma, not a consequence of the recursion. The PHD recursion is itself an approximation of the multi-target Bayes filter. So these claims prove that the mixture is the exact PHD before line L6, and they do not prove that the reported states are close to the true states.
Complexity
After the prediction there are components. Line L3 costs , and line L5 costs for the likelihoods and the new means, and makes components. Merging needs the inverse of each covariance, , and each round scans the remaining components at each. In the worst case each round removes one component, so merging costs . In the best case one round removes all, and the sort for the cap costs . The space is for the covariances. The cost is polynomial in the number of targets and measurements, and there is no enumeration of assignments. The cap keeps bounded from frame to frame.
Properties
- No explicit association. Every measurement updates every component, and the weights do the work that assignments do in other trackers.
- Varying number of targets. Births, deaths, misses and clutter are all in the model, so tracks start and end without extra logic.
- No identities. The PHD is a density, not a set of labeled tracks. The estimates of two frames are not linked.
- Closed form only under the stated model. Linear Gaussian models, constant and , and a Gaussian mixture birth intensity.
- Polynomial cost. The work is about Kalman updates per frame.
- Noisy count. The expected number has a high variance when the number of targets is large, and a single miss drops the weight of a target to about .
Variants and improvements
- Particle PHD. Vo, Singh and Doucet (2005) represent the PHD by weighted particles, as in sequential Monte Carlo, for nonlinear and non-Gaussian models. The estimates then need clustering of the particles.
- Nonlinear Gaussian models. Vo and Ma (2006) replace the Kalman update of each component by an extended or unscented Kalman update. The result is no longer exact.
- Spawning. Targets that split off from other targets add a further linear Gaussian term to the prediction, and the mixture stays closed.
- Cardinalized PHD. The CPHD filter of Mahler (2007) propagates the full distribution of the number of targets with the PHD. Its count is much more stable, at a cost cubic in the number of measurements.
- Labeled filters. Filters built on labeled random finite sets give each target an identity, so the output is a set of tracks.
- Track labels as a post step. A simple fix is to tag each component and pass the tag to the components it creates, then read the tags of the extracted estimates.
When to use it
Use the GM-PHD filter when many targets appear and disappear, the clutter is heavy, and an estimate of the number of targets and their positions in each frame is the main output. It was designed for radar and sonar, and in vision it is used for people, vehicles and cells seen by a detector. When the motion is nonlinear, use the extended or unscented form, or the particle form. If each target must keep one identity over the whole video, add labels or use a tracker that keeps identities, such as MHT. If the number of targets is known and small, JPDA or GNN is simpler.
Pitfalls
- A model outside the closed form. A detection probability that depends on the state, or nonlinear models, break the exact recursion. The usual approximations work but are no longer exact.
- A birth model that misses the entry points. The filter can only start a target where the birth intensity has weight. A birth weight that is too large makes clutter turn into targets.
- Missed detections. One miss multiplies the weight of a target by . With the target falls below the threshold of 0.5 for that frame.
- Close targets. Two targets closer than the merge distance become one component, of weight about 2. The extraction reports the same mean twice.
- A wrong clutter intensity. If is too small, clutter adds targets. If it is too large, true measurements are discounted.
- Pruning too hard. A large threshold removes the weak components that a target needs to recover after a miss.
- Loss of symmetry. Rounding in can make it non-symmetric. The code symmetrizes it after the update.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/phd-filter/. The authors are listed in prov/9HR0MT.jsonl.
"""The Gaussian mixture probability hypothesis density filter (Vo and Ma, 2006).
The PHD D(x) of a multi-target state is a density on the single-target state
space whose integral over a region is the expected number of targets in it.
With linear Gaussian motion and measurement models, constant survival and
detection probabilities pS and pD, and a Gaussian mixture birth intensity, a
Gaussian mixture PHD stays a Gaussian mixture after the prediction and the
update. A component is a triple (w, m, P) of a weight, a mean (a list) and a
covariance (a list of rows). The clutter intensity kappa(z) is a function of
the measurement. Pruning and merging keep the number of components bounded.
"""
import math
def mat_mul(a, b):
return [[sum(a[i][k] * b[k][j] for k in range(len(b))) for j in range(len(b[0]))] for i in range(len(a))]
def transpose(a):
return [list(r) for r in zip(*a)]
def mat_add(a, b):
return [[x + y for x, y in zip(r, s)] for r, s in zip(a, b)]
def mat_vec(a, v):
return [sum(x * y for x, y in zip(r, v)) for r in a]
def inverse_and_det(a):
"""Inverse and determinant of a small nonsingular matrix by Gauss-Jordan elimination."""
n = len(a)
m = [list(map(float, r)) + [1.0 if i == j else 0.0 for j in range(n)] for i, r in enumerate(a)]
det = 1.0
for c in range(n):
p = max(range(c, n), key=lambda r: abs(m[r][c]))
if abs(m[p][c]) < 1e-300:
raise ValueError("singular matrix")
if p != c:
m[c], m[p] = m[p], m[c]
det = -det
piv = m[c][c]
det *= piv
m[c] = [x / piv for x in m[c]]
for r in range(n):
if r != c and m[r][c] != 0.0:
f = m[r][c]
m[r] = [x - f * y for x, y in zip(m[r], m[c])]
return [r[n:] for r in m], det
def quad(v, a_inv):
"""The quadratic form v^T A^-1 v."""
return sum(v[i] * sum(a_inv[i][j] * v[j] for j in range(len(v))) for i in range(len(v)))
def gaussian(z, mean, cov):
"""The density N(z; mean, cov)."""
inv, det = inverse_and_det(cov)
nu = [a - b for a, b in zip(z, mean)]
return math.exp(-0.5 * quad(nu, inv)) / math.sqrt((2 * math.pi) ** len(z) * det)
def predict(comps, f, q, p_s, birth):
"""Prediction of a Gaussian mixture PHD (lines L1 and L2)."""
out = []
ft = transpose(f)
for w, m, p in comps: # @line L1
out.append((p_s * w, mat_vec(f, m), mat_add(mat_mul(mat_mul(f, p), ft), q)))
out.extend(birth) # @line L2
return out
def update(comps, zs, h, r, p_d, kappa):
"""Update of a Gaussian mixture PHD with the measurements zs (lines L3 to L5)."""
ht = transpose(h)
d = len(comps[0][1]) if comps else 0
parts = []
for w, m, p in comps: # @line L3
ph = mat_mul(p, ht)
s = mat_add(mat_mul(h, ph), r)
s_inv, s_det = inverse_and_det(s)
k = mat_mul(ph, s_inv)
kh = mat_mul(k, h)
p_upd = mat_add(p, [[-x for x in row] for row in mat_mul(kh, p)])
p_upd = [[0.5 * (p_upd[i][j] + p_upd[j][i]) for j in range(d)] for i in range(d)]
parts.append((mat_vec(h, m), s_inv, s_det, k, p_upd))
out = [((1.0 - p_d) * w, m, p) for (w, m, p) in comps] # @line L4
for z in zs: # @line L5
terms = []
for (w, m, p), (eta, s_inv, s_det, k, p_upd) in zip(comps, parts):
nu = [a - b for a, b in zip(z, eta)]
lik = math.exp(-0.5 * quad(nu, s_inv)) / math.sqrt((2 * math.pi) ** len(z) * s_det)
terms.append((p_d * w * lik, [a + b for a, b in zip(m, mat_vec(k, nu))], p_upd))
denom = kappa(z) + sum(t[0] for t in terms)
out.extend((wz / denom, mz, pz) for wz, mz, pz in terms)
return out
def prune_and_merge(comps, threshold=1e-5, merge_dist=4.0, max_comps=100):
"""Drop the components with a small weight, merge close ones, keep the largest (line L6)."""
rest = [c for c in comps if c[0] > threshold]
invs = [inverse_and_det(c[2])[0] for c in rest]
alive = list(range(len(rest)))
merged = []
while alive:
j = max(alive, key=lambda i: rest[i][0])
mj = rest[j][1]
group = [i for i in alive if quad([a - b for a, b in zip(rest[i][1], mj)], invs[i]) <= merge_dist]
wt = sum(rest[i][0] for i in group)
d = len(mj)
mean = [sum(rest[i][0] * rest[i][1][a] for i in group) / wt for a in range(d)]
cov = [[0.0] * d for _ in range(d)]
for i in group:
w, m, p = rest[i]
dm = [a - b for a, b in zip(mean, m)]
for a in range(d):
for b in range(d):
cov[a][b] += w * (p[a][b] + dm[a] * dm[b])
cov = [[x / wt for x in row] for row in cov]
merged.append((wt, mean, cov))
gs = set(group)
alive = [i for i in alive if i not in gs]
merged.sort(key=lambda c: -c[0])
return merged[:max_comps]
def extract(comps):
"""The expected number of targets and the state estimates (line L7)."""
n_hat = sum(c[0] for c in comps) # @line L7
states = []
for w, m, _ in comps:
if w > 0.5:
states.extend([list(m)] * int(round(w)))
return n_hat, states
def phd_step(comps, zs, model, p_s, p_d, kappa, birth, threshold=1e-5, merge_dist=4.0, max_comps=100):
"""One frame of the GM-PHD filter. Returns (components, expected number, state estimates)."""
f, q, h, r = model
comps = predict(comps, f, q, p_s, birth)
comps = update(comps, zs, h, r, p_d, kappa)
comps = prune_and_merge(comps, threshold, merge_dist, max_comps) # @line L6
n_hat, states = extract(comps)
return comps, n_hat, states
def phd_density(comps, x):
"""The value of the Gaussian mixture PHD at the state x."""
return sum(w * gaussian(x, m, p) for w, m, p in comps)
def cv_model(q, r):
"""Constant velocity model in 2D with a time step of 1: F, Q, H, R."""
f = [[1.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 1.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]
qm = [[q / 3, 0.0, q / 2, 0.0], [0.0, q / 3, 0.0, q / 2], [q / 2, 0.0, q, 0.0], [0.0, q / 2, 0.0, q]]
h = [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0]]
rm = [[r, 0.0], [0.0, r]]
return f, qm, h, rm
test_phd_filter.py 129 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/phd-filter/. The authors are listed in prov/9HR0MT.jsonl.
import math
import random
from phd_filter import cv_model, extract, gaussian, phd_density, phd_step, predict, prune_and_merge, update
def normal_1d(x, m, v):
return math.exp(-0.5 * (x - m) ** 2 / v) / math.sqrt(2 * math.pi * v)
def test_matches_a_grid_phd_recursion_in_1d():
# 1D model: x' = x + noise(0.5), z = x + noise(0.3)
f, q, h, r = [[1.0]], [[0.5]], [[1.0]], [[0.3]]
p_s, p_d, kap = 0.95, 0.8, 0.05
birth = [(0.1, [0.0], [[4.0]])]
comps = [(1.0, [-3.0], [[1.0]]), (0.7, [4.0], [[0.5]])]
step = 0.1
grid = [-15.0 + step * i for i in range(301)]
mix_1d = lambda cs, x: sum(w * normal_1d(x, m[0], p[0][0]) for w, m, p in cs)
dens = [mix_1d(comps, x) for x in grid]
assert abs(dens[150] - phd_density(comps, [0.0])) < 1e-15
for zs in ([[-2.5], [4.3], [8.0]], [[-1.8], [5.0]]):
# the PHD recursion on the grid, with sums in place of the integrals
pred = []
for x in grid:
s = sum(normal_1d(x, y, 0.5) * dy for y, dy in zip(grid, dens)) * step
pred.append(p_s * s + 0.1 * normal_1d(x, 0.0, 4.0))
new = [(1.0 - p_d) * v for v in pred]
for (z,) in zs:
g = [p_d * normal_1d(z, x, 0.3) * v for x, v in zip(grid, pred)]
denom = kap + sum(g) * step
new = [a + b / denom for a, b in zip(new, g)]
dens = new
comps = update(predict(comps, f, q, p_s, birth), zs, h, r, p_d, lambda z: kap)
gm = [mix_1d(comps, x) for x in grid]
assert max(abs(a - b) for a, b in zip(gm, dens)) < 1e-6
assert abs(sum(c[0] for c in comps) - sum(dens) * step) < 1e-6
def test_no_measurements():
model = cv_model(0.1, 0.25)
comps = [(0.9, [0.0, 0.0, 1.0, 0.0], [[1.0 if i == j else 0.0 for j in range(4)] for i in range(4)])]
birth = [(0.2, [5.0, 5.0, 0.0, 0.0], [[2.0 if i == j else 0.0 for j in range(4)] for i in range(4)])]
out = update(predict(comps, model[0], model[1], 0.98, birth), [], model[2], model[3], 0.9, lambda z: 0.01)
assert abs(sum(c[0] for c in out) - (1 - 0.9) * (0.98 * 0.9 + 0.2)) < 1e-12
assert out[0][1] == [1.0, 0.0, 1.0, 0.0]
def test_each_measurement_adds_at_most_one_target():
rng = random.Random(2006)
f, q, h, r = cv_model(0.1, 0.25)
for _ in range(20):
comps = [(rng.uniform(0.1, 1.5), [rng.uniform(-5, 5), rng.uniform(-5, 5), 0.0, 0.0],
[[1.0 if i == j else 0.0 for j in range(4)] for i in range(4)]) for _ in range(4)]
zs = [[rng.uniform(-6, 6), rng.uniform(-6, 6)] for _ in range(rng.randint(0, 5))]
kap = rng.uniform(0.001, 0.1)
out = update(comps, zs, h, r, 0.9, lambda z: kap)
w = sum(c[0] for c in comps)
# the weights of one measurement sum to its share p_D Σ w q / (κ + p_D Σ w q) < 1
per_z = []
for z in zs:
s = sum(0.9 * c[0] * gaussian(z, c[1][:2], [[c[2][0][0] + 0.25, c[2][0][1]], [c[2][1][0], c[2][1][1] + 0.25]]) for c in comps)
per_z.append(s / (kap + s))
assert all(0.0 <= p < 1.0 for p in per_z)
assert abs(sum(c[0] for c in out) - ((1 - 0.9) * w + sum(per_z))) < 1e-9
def test_merge_keeps_weight_mean_and_second_moment():
comps = [(0.6, [0.0, 0.0], [[1.0, 0.0], [0.0, 1.0]]), (0.3, [0.5, -0.2], [[0.8, 0.1], [0.1, 1.2]]),
(0.2, [0.1, 0.4], [[1.0, 0.0], [0.0, 1.0]]), (0.4, [20.0, 0.0], [[1.0, 0.0], [0.0, 1.0]]),
(1e-7, [5.0, 5.0], [[1.0, 0.0], [0.0, 1.0]])]
out = prune_and_merge(comps, threshold=1e-5, merge_dist=4.0)
assert len(out) == 2
w, m, p = out[0]
group = comps[:3]
assert abs(w - 1.1) < 1e-12
for a in range(2):
assert abs(m[a] - sum(c[0] * c[1][a] for c in group) / 1.1) < 1e-12
for b in range(2):
second = sum(c[0] * (c[2][a][b] + c[1][a] * c[1][b]) for c in group) / 1.1
assert abs(p[a][b] + m[a] * m[b] - second) < 1e-12
assert out[1][0] == 0.4 and out[1][1] == [20.0, 0.0]
n_hat, states = extract(out)
assert abs(n_hat - 1.5) < 1e-12 and len(states) == 1
def poisson(rng, lam):
k, p, limit = 0, 1.0, math.exp(-lam)
while True:
p *= rng.random()
if p < limit:
return k
k += 1
def test_scene_with_births_deaths_and_clutter():
rng = random.Random(2003)
model = cv_model(0.01, 0.25)
# (birth frame, death frame, start state)
targets = [(0, 40, [0.0, 0.0, 1.0, 0.5]), (0, 25, [0.0, 20.0, 1.0, -0.3]), (8, 40, [30.0, 0.0, -0.5, 1.0])]
birth_cov = [[4.0, 0, 0, 0], [0, 4.0, 0, 0], [0, 0, 1.0, 0], [0, 0, 0, 1.0]]
birth = [(0.05, [x, y, 0.0, 0.0], birth_cov) for x, y in ((0.0, 0.0), (0.0, 20.0), (30.0, 0.0))]
area, rate = 60.0 * 60.0, 5.0
kappa = lambda z: rate / area
comps = []
good, counted = 0, 0
for k in range(40):
zs, truth = [], []
for i, (b, d, s0) in enumerate(targets):
if b <= k < d:
t = k - b
x = [s0[0] + t * s0[2], s0[1] + t * s0[3]]
truth.append(x)
if rng.random() < 0.95:
zs.append([x[0] + rng.gauss(0, 0.5), x[1] + rng.gauss(0, 0.5)])
for _ in range(poisson(rng, rate)):
zs.append([rng.uniform(-10, 50), rng.uniform(-10, 50)])
rng.shuffle(zs)
comps, n_hat, est = phd_step(comps, zs, model, 0.99, 0.95, kappa, birth)
assert len(comps) <= 100
if k in (0, 1, 2, 8, 9, 10, 25, 26, 27):
continue # a few frames to settle after a birth or a death
counted += 1
if len(est) == len(truth) and all(min(math.dist(x, e[:2]) for e in est) < 1.5 for x in truth):
good += 1
assert good >= 0.8 * counted
History
Mahler developed finite set statistics in the 1990s as a way to treat multi-target tracking as Bayesian filtering of a random finite set. The full multi-target Bayes filter needs integrals over sets of every size, which cannot be computed for more than a few targets. In 2003 Mahler proposed to propagate only the first moment, the PHD, and derived its prediction and update equations, by analogy with the use of the mean in place of the full density. Vo, Singh and Doucet gave the first general implementation by sequential Monte Carlo in 2005. Vo and Ma found the closed Gaussian mixture form in 2006, together with the pruning, merging and extraction steps used on this page. In 2007 Mahler introduced the cardinalized PHD filter to fix the unstable count of the PHD filter and collected the theory in a book. Later filters on labeled random finite sets gave the targets identities.
References
- Ronald P. S. Mahler, Multitarget Bayes filtering via first-order multitarget moments, IEEE Transactions on Aerospace and Electronic Systems 39(4), 2003, 1152 to 1178, the whole paper (the PHD as the first moment of a random finite set, and the prediction and update equations of the PHD filter)
- Ba-Ngu Vo and Wing-Kin Ma, The Gaussian mixture probability hypothesis density filter, IEEE Transactions on Signal Processing 54(11), 2006, 4091 to 4104, the whole paper (the closed form Gaussian mixture recursion and its assumptions, the pruning, merging and state extraction steps, and the extension to nonlinear models)
- Ba-Ngu Vo, Sumeetpal Singh and Arnaud Doucet, Sequential Monte Carlo methods for multitarget filtering with random finite sets, IEEE Transactions on Aerospace and Electronic Systems 41(4), 2005, 1224 to 1245, the whole paper (the particle form of the PHD filter)
- Ronald Mahler, PHD filters of higher order in target number, IEEE Transactions on Aerospace and Electronic Systems 43(4), 2007, 1523 to 1543, the whole paper (the cardinalized PHD filter)
- Ronald P. S. Mahler, Statistical Multisource-Multitarget Information Fusion, Artech House, 2007, the chapters on random finite sets and on the PHD and CPHD filters
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 9HR0MT Edit this page History Report an error Markdown