© Michael Paluszek and Stephanie Thomas  2019
Michael Paluszek and Stephanie ThomasMATLAB Machine Learning Recipeshttps://doi.org/10.1007/978-1-4842-3916-2_12

12. Multiple Hypothesis Testing

Michael Paluszek1  and Stephanie Thomas1
(1)
Plainsboro, NJ, USA
 

12.1 Overview

Tracking is the process of determining the position of other objects as their position changes with time. Air traffic control radar systems are used to track aircraft. Aircraft in flight must track all nearby objects to avoid collisions and to determine if they are threats. Automobiles with radar cruise control use their radar to track cars in front of them so that the car can maintain safe spacing and avoid a collision.

../images/420697_2_En_12_Chapter/420697_2_En_12_Figa_HTML.gif

When you are driving, you maintain situation awareness by identifying nearby cars and figuring out what they are going to do next. Your brain processes data from your eyes to characterize a car. You track objects by their appearance, since, in general, the cars around you all look different. Of course, at night you only have tail lights so the process is harder. You can often guess what each car is going to do, but sometimes you guess wrong and that can lead to collisions.

Radar systems just see blobs. Cameras should be able to do what your eyes and brain do, but that requires a lot of processing. As noted, at night it is hard to reliably identify a car. As the blobs are measured by radar we want to collect all blobs, as they vary in position and speed, and attach them to a particular car’s track. This way we can reliably predict where it will go next. This leads to the topic of this chapter, track-oriented multiple hypothesis testing (MHT).

Track-oriented MHT is a powerful technique for assigning measurements to tracks of objects when the number of objects is unknown or changing. It is absolutely essential for accurate tracking of multiple objects. MHT terms are defined in Table 12.1.
Table 12.1

Multiple Hypothesis Testing Terms

Term

Definition

Clutter

Transient objects of no interest to the tracking system.

Cluster

A collection of tracks that are linked by common observations.

Error Ellipsoid

An ellipsoidal volume around an estimated position.

Family

A set of tracks with a common root node. At most, one track per family can be included in a hypothesis. A family can at most represent one target.

Gate

A region around an existing track position. Measurements within the gate are associated with the track.

Hypothesis

A set of tracks that do not share any common observations.

N-Scan Pruning

Using the track scores from the last N scans of data to prune tracks. The count starts from a root node. When the tracks are pruned, a new root node is established.

Observation

A measurement that indicates the presence of an object. The observation may be of a target or be spurious.

Pruning

Removal of low-score tracks.

Root Node

An established track to which observations can be attached and which may spawn additional tracks.

Scan

A set of data taken simultaneously.

Target

An object being tracked.

Trajectory

The path of a target.

Track

A trajectory that is propagated.

Track Branch

A track in a family that represents a different data association hypothesis. Only one branch can be correct.

Track Score

The log-likelihood ratio for a track.

Hypotheses are sets of tracks with consistent data, that is, where no measurements are assigned to more than one track. The track-oriented approach recomputes the hypotheses using the newly updated tracks after each scan of data is received. Rather than maintaining, and expanding, hypotheses from scan to scan, the track-oriented approach discards the hypotheses formed on scan k − 1. The tracks that survive pruning are propagated to the next scan k where new tracks are formed, using the new observations, and reformed into hypotheses. Except for the necessity to delete some tracks based upon low probability, no information is lost because the track scores that are maintained contain all the relevant statistical data.

The software in this chapter uses a powerful track-pruning algorithm that does the pruning in one step. Because of its speed, ad-hoc pruning methods are not required, leading to more robust and reliable results. The track management software is, as a consequence, quite simple.

The MHT Module requires the GNU Linear Programming Kit (GLPK; http://​www.​gnu.​org/​software/​glpk/​) and specifically, the MATLAB mex wrapper GLPKMEX (http://​glpkmex.​sourceforge.​net). Both are distributed under the GNU license. Both the GLPK library and the GLPKMEX program are operating-system-dependent and must be compiled from the source code on your computer. Once GLPK is installed, the mex must be generated from MATLAB from the GLPKMEX source code.

The command that is executed from MATLAB to create the mex should look like:

 mex -v -I/usr/local/include glpkcc.cpp /usr/local/lib/libglpk.a  

where the “v” specifies verbose printout and you should replace /usr/local with your operating-system dependent path to your installation of GLPK. The resulting mex file (Mac) is:

 glpkcc.mexmaci64  

The MHT software was tested with GLPK version 4.47 and GLPKMEX version 2.11.

12.2 Theory

12.2.1 Introduction

Figure 12.1 shows the general tracking problem in the context of automobile tracking. Two scans of data are shown. When the first scan is done, there are two tracks. The uncertainty ellipsoids are shown and they are based on all previous information. In the k − 1 scan (a scan is a set of measurements taken at the same time), three measurements are observed. Each scan has multiple measurements, the measurements in each new scan are numbered beginning with 1, and the measurement numbers are not meant to imply any correlation across subsequent scans. One and 3 are within the ellipsoids of the two tracks, but 2 is in both. It may be a measurement of either of the tracks or a spurious measurement. In scan k, four measurements are taken. Only measurement 4 is in one of the uncertainty ellipsoids. Three may be interpreted as spurious, but it is actually because of a new track from a third vehicle that it separates from the blue track. Measurement 1 is outside of the red ellipsoid, but is actually a good measurement of the red track and (if correctly interpreted) indicates that the model is erroneous. 4 is a good measurement of the blue track and indicates that the model is valid. Measurement 2 of scan k is outside both uncertainty ellipsoids.

The illustration shows how the tracking system should behave, but without the tracks it would be difficult to interpret the measurements. As shown a measurement can be:
  1. 1.

    Valid

     
  2. 2.

    Spurious

     
  3. 3.

    A new track

     
“Spurious” means that the measurement is not associated with any tracked object and isn’t a new track. We can’t determine the nature of any measurement without going through the MHT process.
../images/420697_2_En_12_Chapter/420697_2_En_12_Fig1_HTML.png
Figure 12.1

Tracking problem.

We define a contact as an observation where the signal-to-noise ratio is above a certain threshold. The observation then constitutes a measurement. Low signal-to-noise ratio observations can happen in both optical and radar systems. Thresholding reduces the number of observations that need to be associated with tracks, but may lose valid data. An alternative is to treat all observations as valid, but adjust the measurement error accordingly.

Valid measurements must then be assigned to tracks. An ideal tracking system would be able to categorize each measurement accurately and then assign them to the correct track. The system must also be able to identify new tracks and remove tracks that no longer exist. A tracking system may have to deal with hundreds of objects (perhaps after a collision or because of debris in the road).

A sophisticated system should be able to work with multiple objects as groups or clusters if the objects are more or less moving in the same direction. This reduces the number of states a system must handle. If a system handles groups, then it must be able to handle groups spawning from groups.

If we were confident that we were only tracking one vehicle, all of the data might be incorporated into the state estimate. An alternative is to incorporate only the data within the covariance ellipsoids and treat the remainders as outliers. If the latter strategy were taken, it would be sensible to remember that data in case future measurements were also “outliers,” in which case the filter might go back and incorporate different sets of outliers into the solution. This could easily happen if the model were invalid, for example, if the vehicle, which had been cruising at a constant speed, suddenly began maneuvering and the filter model did not allow for maneuvers.

The multiple model filters helps with the erroneous model problem and should be used any time a vehicle might change mode. It does not tell us how many vehicles we are tracking, however. With multiple models, each model would have its own error ellipsoids and the measurements would fit one better than the other, assuming that one of the models was a reasonable model for the tracked vehicle in its current mode.

12.2.2 Example

Referring to Figure 12.1 in the first scan, we have three measurements. 1 and 3 are associated with existing tracks and are used to update those tracks. 2 could be associated with either. It might be a spurious measurement or it could be a new track, so the algorithm forms a new hypothesis. In scan 2 measurement 4 is associated with the blue track. 1, 2, and 3 are not within the error ellipsoids of either track. Since the figure shows the true track, we can see that 1 is associated with the red track. Both 1 and 2 are just outside the error ellipsoid for the red track. Measurement 2 in scan 2 might be consistent with measurement 2 in scan 1 and could result in a new track. Measurement 3 in scan 2 is a new track, but we likely don’t have enough information to create a track until we have more scans of data.

12.2.3 Algorithm

In classical multiple target tracking, [24], the problem is divided into two steps, association and estimation. Step 1 associates contacts with targets and step 2 estimates each target’s state. Complications arise when there is more than one reasonable way to associate contacts with targets. The multiple hypothesis testing (MHT) approach is to form alternative hypotheses to explain the source of the observations. Each hypothesis assigns observations to targets or false alarms.

There are two basic approaches to MHT [3]. The first, following Reid [21], operates within a structure in which hypotheses are continually maintained and updated as observation data are received. In the second, the track-oriented approach to MHT, tracks are initiated, updated, and scored before being formed into hypotheses. The scoring process consists of comparing the likelihood that the track represents a true target versus the likelihood that it is a collation of false alarms. Thus, unlikely tracks can be deleted before the next stage, in which tracks are formed into a hypothesis. It is a good thing to discard the old hypotheses and start from scratch each time because this approach maintains the important track data while preventing an explosion of an impractically large number of hypotheses.

The track-oriented approach recomputes the hypotheses using the newly updated tracks after each scan of data is received. Rather than maintaining, and expanding, hypotheses from scan to scan, the track-oriented approach discards the hypotheses formed on scan k-1. The tracks that survive pruning are predicted to the next scan k where new tracks are formed, using the new observations, and reformed into hypotheses. Except for the necessity to delete some tracks based upon low probability or N-scan pruning, no information is lost because the track scores that are maintained contain all the relevant statistical data.

Track scoring is done using log-likelihood ratios. LR is the likelihood ratio, LLR the log-likelihood ratio, and L is the likelihood.
$$\displaystyle \begin{aligned} L(K) = \log[\mathrm{LR}(K)] = \sum_{k=1}^K\left[\mathrm{LLR}_K(k) + \mathrm{LLR}_S(k)\right] + \log[L_0] \end{aligned} $$
(12.1)
where the subscript K denotes kinematic (position) and the subscript S denotes signal (measurement). It is assumed that the two are statistically independent.
$$\displaystyle \begin{aligned} L_0 = \frac{P_0(H_1)}{P_0(H_0)} \end{aligned} $$
(12.2)
where H 1 and H 0 are the true target and false alarm hypotheses. $$\log $$ is a natural logarithm. The likelihood ratio for the kinematic data is the probability that the data are a result of the true target divided by the probability that the data are due to a false alarm:
$$\displaystyle \begin{aligned} \mathrm{LR}_K = \frac{p(D_K|H_1)}{p(D_K|H_0)} = \frac{e^{-d^2/2}/((2\pi)^{M/2}\sqrt{|S|}}{1/V_C} \end{aligned} $$
(12.3)
where
  1. 1.

    M in the denominator of the third formula is the measurement dimension

     
  2. 2.

    VC is the measurement volume

     
  3. 3.

    S = HPTT + R the measurement residual covariance matrix

     
  4. 4.

    d 2 = yTS −1y is the normalized statistical distance for the measurement

     
The statistical distance is defined by the residual y, the difference between the measurement and the estimated measurement, and the covariance matrix S. The numerator is the multivariate Gaussian.

12.2.4 Measurement Assignment and Tracks

The following are the rules for each measurement:
  1. 1.

    Each measurement creates a new track.

     
  2. 2.

    Each measurement in each gate updates the existing track. If there is more than one measurement in a gate, the existing track is duplicated with the new measurement.

     
  3. 3.

    All existing tracks are updated with a “missed” measurement, creating a new track.

     
Figure 12.2 gives an example. We are starting with two tracks. There are two tracks and three measurements. All three measurements are in the gate for track 1, but only one is in the gate for track 2. Each measurement produces a new track. The three measurements produce three tracks based on track 1 and the one measurement produces one track based on track 2.
There are three types of tracks created from each scan, in general:
  1. 1.

    An existing track is updated with a new measurement, assuming it corresponds to that track.

     
  2. 2.

    An existing track is carried along with no update, assuming that no measurement was made for it in that scan.

     
  3. 3.

    A completely new track is generated for each measurement, assuming that the measurement represents a new object.

     
Each track also spawns a new track assuming that there was no measurement for the track. Thus in this case, three measurements and two tracks result in nine new tracks. Tracks 7–9 are initiated based only on the measurement, which may not be enough information to initiate the full state vector. If this is the case, there would be an infinite number of tracks associated with each measurement, not just one new track. If we have a radar measurement we have azimuth, elevation, range, and range rate. This gives all position states and one velocity state.
../images/420697_2_En_12_Chapter/420697_2_En_12_Fig2_HTML.jpg
Figure 12.2

Measurement and gates. M0 is an “absent” measurement. An absent measurement is one that should exist, but does not.

12.2.5 Hypothesis Formation

In MHT, a valid hypothesis is any compatible set of tracks. In order for two or more tracks to be compatible, they cannot describe the same object, and they cannot share the same measurement at any of the scans. The task in hypothesis formation is to find one or more combinations of tracks that: 1) are compatible, and 2) maximize some performance function.

Before discussing the method of hypothesis formation, it is useful to first consider track formation and how tracks are associated with unique objects. New tracks may be formed in one of two ways:
  1. 1.

    The new track is based on some existing track, with the addition of a new measurement.

     
  2. 2.

    The new track is NOT based on any existing tracks; it is based solely on a single new measurement.

     

Recall that each track is formed as a sequence of measurements across multiple scans. In addition to the raw measurement history, every track also contains a history of state and covariance data that is computed from a Kalman Filter. Kalman Filters are explored in Chapter 8. When a new measurement is appended to an existing track, we are spawning a new track that includes all of the original track’s measurements, plus this new measurement. Therefore, the new track is describing the same object as the original track.

A new measurement can also be used to generate a completely new track that is independent of past measurements. When this is done, we are effectively saying that the measurement does not describe any of the objects that are already being tracked. It therefore must correspond to a new/different object.

In this way, each track is given an object ID to distinguish which object it describes. Within the context of track-tree diagrams, all of the tracks inside the same track-tree have the same object ID. For example, if at some point there are 10 separate track-trees, this means that 10 separate objects are being tracked in the MHT system. When a valid hypothesis is formed, it may turn out that only a few of these objects have compatible tracks.

The hypothesis formation step is formulated as a mixed integer linear program (MILP) and solved using GLPK. Each track is given an aggregate score that reflects the component scores attained from each measurement. The MILP formulation is constructed to select a set of tracks that add up to give the highest score, such that:
  1. 1.

    No two tracks have the same object ID

     
  2. 2.

    No two tracks have the same measurement index for any scan

     

In addition, we extend the formulation with an option to solve for multiple hypotheses, rather than just one. The algorithm will return the “M best” hypotheses, in descending order of score. This enables tracks to be preserved from alternate hypotheses that may be very close in score to the best.

12.2.6 Track Pruning

The N-scan track pruning is carried out every step using the last n scans of data. We employ a pruning method in which the following tracks are preserved:
  • Tracks with the “N” highest scores

  • Tracks that are included in the “M best” hypotheses

  • Tracks that have both 1) the object ID and 2) the first “P” measurements found in the “M best” hypotheses.

We use the results of hypothesis formation to guide track pruning. The parameters N, M, and P can be tuned to improve performance. The objective with pruning is to reduce the number of tracks as much as possible, while not removing any tracks that should be part of the actual true hypothesis.

The second item listed above is to preserve all tracks included in the “M best” hypotheses. Each of these is a full path through a track-tree, which is clear. The third item listed above is similar, but less constrained. Consider one of the tracks in the “M best” hypotheses. We will preserve this full track. In addition, we will preserve all tracks that stem from scan “P” of this track.

Figure 12.3 provides an example of which tracks in a track-tree might be preserved. The diagram shows 17 different tracks over five scans. The green track represents one of the tracks found in the set of “M best” hypotheses, from the hypothesis formation step. This track would be preserved. The orange tracks all stem from the node in this track at scan 2. These would be preserved if we set P = 2 from the description above.
../images/420697_2_En_12_Chapter/420697_2_En_12_Fig3_HTML.png
Figure 12.3

Track pruning example. This shows multiple scans (simultaneous measurements) and how they might be used to remove tracks that do not fit all of the data.

12.3 Billiard Ball Kalman Filter

12.3.1 Problem

You want to estimate the trajectory of multiple billiard balls. In the billiard ball example, we assume that we have multiple balls moving at once. Let’s say we have a video camera placed above the table, and we have software that can measure the position of each ball for each video frame. That software cannot, however, determine the identity of any ball. This is where MHT comes in. We use MHT to develop a set of tracks for the moving balls.

12.3.2 Solution

The solution is to create a linear Kalman Filter.

12.3.3 How It Works

The core estimation algorithm for the MHT system is the Kalman Filter. The Kalman Filter consists of a simulation of the dynamics and an algorithm to incorporate the measurements. For the examples in this chapter we use a fixed gain Kalman Filter. The model is:
$$\displaystyle \begin{aligned} \begin{array}{rcl} x_{k+1} = a x_k + b u_k \end{array} \end{aligned} $$
(12.4)
$$\displaystyle \begin{aligned} \begin{array}{rcl} y_k = c x_k \end{array} \end{aligned} $$
(12.5)
xk is the state, a column vector that includes position and velocity. yk is the measurement vector. uk is the input, the accelerations on the billiard balls. c relates the state to the measurement, y. If the only measurement were position then:
$$\displaystyle \begin{aligned} c = \left[\begin{array}{ll} 1 & 0 \end{array} \right] \end{aligned} $$
(12.6)
This is a discrete time equation. Since the second column is zero, it is only measuring position. Let’s assume we have no input accelerations. Also assume that the time step is τ. Then our equations become:
$$\displaystyle \begin{aligned} \begin{array}{rcl} \left[\begin{array}{l} s\\ v \end{array} \right]_{k+1} &=& \left[\begin{array}{ll} 1 & \tau\\ 0 & 1 \end{array} \right] \left[\begin{array}{l} s\\ v \end{array} \right]_k \end{array} \end{aligned} $$
(12.7)
$$\displaystyle \begin{aligned} \begin{array}{rcl} y_k &=& \left[\begin{array}{ll} 1 & 0 \end{array} \right] \left[\begin{array}{l} s\\ v \end{array} \right]_k \end{array} \end{aligned} $$
(12.8)
where s is position and v is velocity, yk = s. This says that the new position is the old position plus velocity times time. Our measurement is just position. If there are no external accelerations, the velocity is constant. If we can’t measure acceleration directly then this is our model. Our filter will estimate velocity given changes in position.

A track, in this case, is a sequence of s. MHT assigns measurements, y to the track. If we know that we have only one object and that our sensor is measuring the track accurately, and doesn’t have any false measurements or possibility of missing measurements, we can use the Kalman Filter directly.

The KFBilliardsDemo simulates billiard balls. It includes two functions to represent the dynamics. The first is RHSBilliards, which is the right-hand-side of the billiards ball dynamics, which were just given above. This computes the position and velocity given external accelerations. The function BilliardCollision applies conservation of momentum whenever a ball hits a bumper. Balls can’t collide with other balls. The first part of the script is the simulation that generates a measurement vector for all of the balls. The second part of the script initializes one Kalman Filter per ball. This script perfectly assigns measurements to each track. The function KFPredict is the prediction step, i.e., the simulation of the ball motion. It uses the linear model described above. KFUpdate incorporates the measurements. MHTDistance is just for information purposes. The initial positions and velocity vectors of the balls are random. The script fixes the seed for the random number generator to make every run the same, which is handy for debugging. If you comment out this code each run will be different.

Here, we initialize the ball positions.

  % The number of balls and the random initial position and velocity
 d       = struct( ’nBalls’,3, ’xLim’,[-1 1],  ’yLim’, [-1 1]);
 sigP    = 0.4;  % 1 sigma noise for the position
 sigV    = 1;  % 1 sigma noise for the velocity
 sigMeas = 0.00000001;  % 1 sigma noise for the measurement
  % Set the initial state for  2 sets of position and velocity
 x  =  zeros (4*d.nBalls,1);
 rN =  rand (4*d.nBalls,1);
for k = 1:d.nBalls
   j        = 4*k-3;
   x(j  ,1) = sigP*(rN(j  ) - 0.5);
   x(j+1,1) = sigV*(rN(j+1) - 0.5);
   x(j+2,1) = sigP*(rN(j+2) - 0.5);
   x(j+3,1) = sigV*(rN(j+3) - 0.5);
end

We then simulate them. Their motion is in a straight line unless they collide with a bumper.

  % Sensor measurements
 nM  = 2*d.nBalls;
 y   =  zeros (nM,n);
 iY  =  zeros (nM,1);
for k = 1:d.nBalls
   j = 2*k-1;
   iY(j  )  = 4*k-3;
   iY(j+1)  = 4*k-1;
end
for k = 1:n
    % Collisions
   x = BilliardCollision( x, d );
    % Plotting
   xP(:,k)       = x;
    % Integrate using a 4th Order Runge-Kutta integrator
   x = RungeKutta(@RHSBilliards, 0, x, dT, d );
    % Measurements with Gaussian random noise
   y(:,k) = x(iY) + sigMeas* randn (nM,1);
end

We then process the measurements through the Kalman Filter. KFPredict predicts the next position of the balls and KFUpdate incorporates measurements. The prediction step does not know about collisions.

  %% Implement the Kalman Filter
  % Covariances
 r0      = sigMeas^2*[1;1];      % Measurement covariance
 q0      = [1;60;1;60];       % The baseline plant covariance diagonal
 p0      = [0.1;1;0.1;1];        % Initial state covariance matrix diagonal
  % Plant model
 a       = [1 dT;0 1];
 b       = [dT^2/2;dT];
 zA      =  zeros (2,2);
 zB      =  zeros (2,1);
  % Create the Kalman Filter data structures. a is for two balls.
for k = 1:d.nBalls
   kf(k) = KFInitialize(  ’kf’,  ’m’, x0(4*k-3:4*k),  ’x’, x0(4*k-3:4*k),...
                          ’a’, [a zA;zA a],  ’b’, [b zB;zB b], ’u’,[0;0],...
                          ’h’, [1 0 0 0;0 0 1 0],  ’p’,  diag (p0), ...
                          ’q’,  diag (q0), ’r’,  diag (r0) );
   end
  % Size arrays for plotting
 pUKF =  zeros (4*d.nBalls,n);
 xUKF =  zeros (4*d.nBalls,n);
 t    = 0;
for k = 1:n
    % Run the filters
    for j = 1:d.nBalls
      % Store for plotting
     i           = 4*j-3:4*j;
     pUKF(i,k)   =  diag (kf(j).p);
     xUKF(i,k)   = kf(j).m;
      % State update
     kf(j).t   = t;
     kf(j)     = KFPredict( kf(j) );
      % Incorporate the measurements
     i         = 2*j-1:2*j;
     kf(j).y   = y(i,k);
     kf(j)     = KFUpdate( kf(j) );
    end
   t = t + dT;
end
The results of the Kalman Filter demo are shown in Figure 12.4, Figure 12.5 and Figure 12.6. The covariances and states for all balls are plotted, but we only show one here. The covariances always follow the same trend with time. As the filter accumulates measurements it adjusts the covariances based on the ratio between the model covariance, i.e., how accurate the model is assumed to be, and the measurement covariances. The covariances are not related to the actual measurements at all. The Kalman Filter errors are shown in Figure 12.6. They are large whenever the ball hits a bumper, since the model does not include collisions with the bumpers. They rapidly decrease because our measurements have little noise.
../images/420697_2_En_12_Chapter/420697_2_En_12_Fig4_HTML.png
Figure 12.4

The four balls on the billiards table.

../images/420697_2_En_12_Chapter/420697_2_En_12_Fig5_HTML.png
Figure 12.5

The filter covariances.

../images/420697_2_En_12_Chapter/420697_2_En_12_Fig6_HTML.png
Figure 12.6

The filter errors.

The following code, excerpted from the above demo, is specialized drawing code to show the billiards on the table. It calls plot for each ball. Colors are taken from the array c and are blue, green, red, cyan, magenta, yellow, and black. You can run this from the command line once you have computed xP and yP, which are the x and y positions of the balls. The code uses the legend handles to associate the balls with the tracks in the plot in the legend. It manually sets the limits (gca as a handle to the current axes).

  % Plot the simulation results
 NewFigure(  ’Billiard␣Balls’ )
 c  =  ’bgrcmyk’;
 kX = 1;
 kY = 3;
 s  =  cell (1,d.nBalls);
 l = [];
for k = 1:d.nBalls
    plot(xP(kX,1),xP(kY,1),[ ’o’,c(k)])
    hold on
   l(k) =  plot (xP(kX,:),xP(kY,:),c(k));
   kX    = kX + 4;
   kY    = kY + 4;
   s{k} =  sprintf ( ’Ball␣%d’,k);
end
xlabel( ’x␣(m)’);
ylabel( ’y␣(m)’);
set(gca, ’ylim’,d.yLim, ’xlim’,d.xLim);
legend(l,s)
grid  on

You can change the covariances, sigP,sigV,sigMeas in the script and see how it impacts the errors and the covariances.

12.4 Billiard Ball MHT

12.4.1 Problem

You want to estimate the trajectory of multiple billiard balls.

12.4.2 Solution

The solution is to create an MHT system with a linear Kalman Filter. This example involves billiard balls bouncing off of the bumpers of a billiard table. The model does not include the bumper collisions.

12.4.3 How It Works

The following code adds the MHT functionality. It first runs the demo, just like in the example above, and then tries to sort the measurements into tracks. It only has two balls. When you run the demo you will see the graphical user interface (GUI), Figure 12.7, and the Tree, Figure 12.8, change as the simulation progresses. We only include the MHT code in the following listing.

  % Create the track data data structure
 mhtData = MHTInitialize( ’probability␣false␣alarm’, 0.001,...
                          ’probability␣of␣signal␣if␣target␣present’, 0.999,...
                          ’probability␣of␣signal␣if␣target␣absent’,  0.001,...
                          ’probability␣of␣detection’, 1, ...
                          ’measurement␣volume’, 1.0, ...
                          ’number␣of␣scans’, 3, ...
                          ’gate’, 0.2,...
                          ’m␣best’, 2,...
                          ’number␣of␣tracks’, 1,...
                          ’scan␣to␣track␣function’,@ScanToTrackBilliards ,...
                          ’scan␣to␣track␣data’,struct( ’r’, diag (r0), ’p’, diag (p0)),...
                          ’distance␣function’,@MHTDistance ,...
                          ’hypothesis␣scan␣last’, 0,...
                          ’filter␣data’,kf(1),...
                          ’prune␣tracks’, 1,...
                          ’remove␣duplicate␣tracks␣across␣all␣trees’,1,...
                          ’average␣score␣history␣weight’,0.01,...
                          ’filter␣type’, ’kf’);
  % Create the tracks
for k = 1:d.nBalls
         trk(k) = MHTInitializeTrk( kf(k) );
end
  % Size arrays
 b = MHTTrkToB( trk );
  %% Initialize MHT GUI
 MHTGUI;
 MLog( ’init’)
 MLog( ’name’, ’Billiards␣Demo’)
 TOMHTTreeAnimation(  ’initialize’, trk );
 TOMHTTreeAnimation(  ’update’, trk );
 t = 0;
for k = 1:n
    % Get the measurements - zScan.data
   z =  reshape ( y(:,k), 2, d.nBalls );
   zScan = AddScan( z(:,1) );
    for j = 2:size(z,2)
     zScan = AddScan( z(:,j),[],zScan);
    end
    % Manage the tracks and generate hypotheses
   [b, trk, sol, hyp] = MHTTrackMgmt( b, trk, zScan, mhtData, k, t );
    % Update MHTGUI display
    if( ~isempty(zScan) && graphicsOn )
      if (treeAnimationOn)
       TOMHTTreeAnimation(  ’update’, trk );
      end
     MHTGUI(trk,sol, ’hide’);
      drawnow
    end
   t = t + dT;
end
  % Show the final GUI
if (~treeAnimationOn)
   TOMHTTreeAnimation(  ’update’, trk );
end
if (~graphicsOn)
   MHTGUI(trk,sol, ’hide’);
end
 MHTGUI;
The parameter pairs in MHTInitialize are described in Table 12.2.
Table 12.2

Multiple Hypothesis Testing Parameters

Term

Definition

’probability false alarm’

The probability that a measurement is spurious

’probability of signal if target present’

The probability of getting a signal if the target is present

’probability of signal if target absent’

The probability of getting a signal if the target is absent

’probability of detection’

Probability of detection of a target

’measurement volume’

Scales the likelihood ratio.

’number of scans’

The number of scans to consider in hypothesis formulation

’gate’

The size of the gate

’m best’

Number of hypotheses to consider

’number of tracks’

Number of tracks to maintain

’scan to track function’

Pointer to the scan to track function. This is custom for each application.

’scan to track data’

Data for the scan to track function

’distance function’

Pointer for the MHT distance function. Different definitions are possible.

’hypothesis scan last’

The last scan used in a hypothesis

’prune tracks’

Prune tracks if true

’filter type’

Type of Kalman Filter

’filter data’

Data for the Kalman Filter

’remove duplicate tracks across all trees’

If true removed duplicate tracks from all trees

’average score history weight’

A number to multiply the average score history

’create track’’

If entered it will create a track instead of using an existing track

Figure 12.7 shows the MHT GUI. This shows the GUI at the end of the simulation. The table shows scans on the x-axis and tracks on the y-axis (vertical). Each track is numbered as xxx.yyy, where xxx is the track and yyy is the tag. Every track is assigned a new tag number. For example, 95.542 is track 95 and tag 542 means it is the 542nd track generated. The numbers in the table show the measurements associated with the track and the scan. TRK 3.21 and TRK 3.57 are duplicates. In both cases one measurement per scan is associated with the TRK. Their scores are the same because they are consistent. We can only pick one or the other for our hypothesis. TRK 95.542 doesn’t get a measurement from scan 77, but for the rest of the scans it gets measurement 2. Scans 77 through 80 are active. A scan is a set of four position measurements. The summary shows there are seven active tracks, but we know (although the software does not necessarily) that there are only four balls in play. The number of scans are the ones currently in use to determine valid tracks. There are two active hypotheses.
../images/420697_2_En_12_Chapter/420697_2_En_12_Fig7_HTML.jpg
Figure 12.7

The multiple hypothesis testing (MHT) graphic user interface (GUI).

Figure 12.8 shows the decision tree. You can see that with scan 80, two new tracks are created. This means that MHT thinks that there could be as many as four tracks. However, at this point only two tracks, 3 and 95, have multiple measurements associated with them.
../images/420697_2_En_12_Chapter/420697_2_En_12_Fig8_HTML.png
Figure 12.8

The MHT tree. The blue bars gives the score assigned to each track. Longer is better. The numbers in the framed black boxes are the track numbers.

Figure 12.9 shows the information window. This shows the MHT algorithm’s thinking. It gives the decisions made with each scan.
../images/420697_2_En_12_Chapter/420697_2_En_12_Fig9_HTML.jpg
Figure 12.9

The MHT information window. It tells you what the MHT algorithm is thinking.

The demo shows that the MHT algorithm correctly associates measurements with tracks.

12.5 One-Dimensional Motion

12.5.1 Problem

You want to estimate the position of an object moving in one direction with unknown accelerations.

12.5.2 Solution

The solution is to create a linear Kalman Filter with an acceleration state.

12.5.3 How It Works

In this demo, we have a model of objects that includes an unknown acceleration state.
$$\displaystyle \begin{aligned} \begin{array}{rcl} \left[\begin{array}{l} s\\ v\\ a \end{array} \right]_{k+1} &=& \left[\begin{array}{lll} 1 & \tau & \frac{1}{2}\tau^2\\ 0 & 1& \tau\\ 0 & 0 & 1 \end{array} \right] \left[\begin{array}{l} s\\ v\\ a \end{array} \right]_k \end{array} \end{aligned} $$
(12.9)
$$\displaystyle \begin{aligned} \begin{array}{rcl} y_k &=& \left[\begin{array}{lll} 1 & 0 & 0 \end{array} \right] \left[\begin{array}{l} s\\ v\\ a \end{array} \right]_k \end{array} \end{aligned} $$
(12.10)
where s is position, v is velocity and a is acceleration. yk = s. τ is the time step. The input to the acceleration state is the time rate of change of acceleration.

The function DoubleIntegratorWithAccel creates the matrices shown above:

 >> [a, b]  = DoubleIntegratorWithAccel( 0.5 )
 a =
     1.0000    0.5000    0.1250
          0    1.0000    0.5000
          0         0    1.0000
 b =
      0
      0
      1  

with τ = 0.5 s.

We will set up the simulation so that one object has no acceleration, but starts in front of the other. The other will overtake the first. We want to see if MHT can sort out the trajectories. Passing would happen all the time with autonomous driving.

The following code implements the Kalman Filters for two vehicles. The simulation runs first to generate the measurements. The Kalman Filter runs next. Note that the plot array is updated after the filter update. This keeps it in sync with the simulation.

  %% Run the Kalman Filter
  % The covariances
 r      = r(1,1);
 q      =  diag ([0.5*aRand*dT^2;aRand*dT;aRand].^2 + q0);
  % Create the Kalman Filter data structures
 d1    = KFInitialize(  ’kf’,  ’m’, [0;0;0],   ’x’, [0;0;0],  ’a’, a,  ’b’, b,  ’u’,0,...
                        ’h’, h(1,1:3),  ’p’,  diag (p0),  ’q’, q,  ’r’, r );
 d2    = d1;
 d1.m   = x(1:3,1) +  sqrt (p0).* rand (3,1);
 d2.m   = x(4:6,1) +  sqrt (p0).* rand (3,1);
 xE    =  zeros (6,n);
for k = 1:n
   d1      = KFPredict( d1 );
   d1.y    = z(1,k);
   d1      = KFUpdate( d1 );
   d2      = KFPredict( d2 );
   d2.y    = z(2,k);
   d2      = KFUpdate( d2 );
   xE(:,k) = [d1.m;d2.m];
end

We use PlotSet with the argument ’plot set’ to group inputs and the argument ’legend’ to put legends on each plot. ’plot set’ takes a cell array of 1 × n arrays and ’legend’ takes a cell array of cell arrays as inputs. We don’t need to numerically integrate the equations of motion because the state equations have already done that. You can always propagate a linear model in this fashion. We set the model noise matrix using aRand, but don’t actually input any random accelerations. As written, our model is perfect, which is never true in a real system, hence the need for model uncertainty.

Figure 12.10 shows the states and the errors. The filters track all three states for both objects pretty well. The acceleration and velocity estimates converge with 10 s. It does a good job of estimating the fixed disturbance acceleration despite only having a position, s, measurement.
../images/420697_2_En_12_Chapter/420697_2_En_12_Fig10_HTML.png
Figure 12.10

The object states and filter errors.

12.6 One-Dimensional Motion with Track Association

The next problem is one in which we need to associate measurements with a track.

12.6.1 Problem

You want to estimate the position of an object moving in one direction with measurements that need to be associated with a track.

12.6.2 Solution

The solution is to create an MHT system with the Kalman Filter as the state estimator.

12.6.3 How It Works

The MHT code is shown below. We append the MHT software to the script shown above. The Kalman Filters are embedded in the MHT software. We first run the simulation and gather the measurements and then process them in the MHT code.

  % Initialize the MHT parameters
 [mhtData, trk] = MHTInitialize( ’probability␣false␣alarm’, 0.001,...
                                  ’probability␣of␣signal␣if␣target␣present’, 0.999,...
                                  ’probability␣of␣signal␣if␣target␣absent’, 0.001,...
                                  ’probability␣of␣detection’, 1, ...
                                  ’measurement␣volume’, 1.0, ...
                                  ’number␣of␣scans’, 3, ...
                                  ’gate’, 0.2,...
                                  ’m␣best’, 2,...
                                  ’number␣of␣tracks’, 1,...
                                  ’scan␣to␣track␣function’,@ScanToTrack1D ,...
                                  ’scan␣to␣track␣data’,struct( ’v’,0),...
                                  ’distance␣function’,@MHTDistance ,...
                                  ’hypothesis␣scan␣last’, 0,...
                                  ’prune␣tracks’, true,...
                                  ’filter␣type’, ’kf’,...
                                  ’filter␣data’, f,...
                                  ’remove␣duplicate␣tracks␣across␣all␣trees’,true,...
                                  ’average␣score␣history␣weight’,0.01,...
                                  ’create␣track’,  ’’);
  % Size arrays
 m               =  zeros (3,n);
 p               =  zeros (3,n);
 scan            =  cell (1,n);
 b               = MHTTrkToB( trk );
 TOMHTTreeAnimation(  ’initialize’, trk );
 TOMHTTreeAnimation(  ’update’, trk );
  % Initialize the MHT GUI
 MHTGUI;
 MLog( ’init’)
 MLog( ’name’, ’MHT␣1D␣Demo’)
 t = 0;
for k = 1:n
    % Get the measurements
   zScan = AddScan( z(1,k) );
   zScan = AddScan( z(2,k), [], zScan );
    % Manage the tracks
   [b, trk, sol, hyp] = MHTTrackMgmt( b, trk, zScan, mhtData, k, t );
    % Update MHTGUI display
   MHTGUI(trk,sol, ’update’);
    % A guess for the initial velocity of any new track
    for j = 1:length(trk)
       mhtData.fScanToTrackData.v = mhtData.fScanToTrackData.v + trk(j).m(1);
    end
   mhtData.fScanToTrackData.v = mhtData.fScanToTrackData.v/ length (trk);
    % Animate the tree
   TOMHTTreeAnimation(  ’update’, trk );
    drawnow;
   t = t + dT;
end
Figure 12.11 shows the states and the errors. The MHT-hypothesized tracks are a good fit to the data.
../images/420697_2_En_12_Chapter/420697_2_En_12_Fig11_HTML.png
Figure 12.11

The MHT object states and estimated states. The colors are switched between plots.

Figure 12.12 shows the MHT GUI and the tree. Track 1 contains only measurements from object 2. Track 2 contains only measurements from object 1. Three hundred and fifty-four and 360 are spurious tracks. Three hundred and fifty-four has a measurement 1 for scan 177, but none for the following scan. Three hundred and sixty was created on scan 180 and has just one measurement. One and 2 have the same score. The results show that the MHT software has successfully sorted out the measurements and assigned them correctly. At this point, the end of the sim, four scans are active.
../images/420697_2_En_12_Chapter/420697_2_En_12_Fig12_HTML.png
Figure 12.12

The GUI and MHT tree. The tree shows the MHT decision process.

12.7 Summary

This chapter has demonstrated the fundamentals of multiple hypothesis testing. Table 12.3 lists the functions and scripts included in the companion code.
Table 12.3

Chapter Code Listing

File

Description

AddScan

Add a scan to the data.

CheckForDuplicateTracks

Look through the recorded tracks for duplicates.

MHTDistanceUKF

Compute the MHT distance.

MHTGUI.fig

Saved layout data for the MHT GUI.

MHTGUI

GUI for the MHT software.

MHTHypothesisDisplay

Display hypotheses in a GUI.

MHTInitialize

Initialize the MHT algorithm.

MHTInitializeTrk

Initialize a track.

MHTLLRUpdate

Update the log likelihood ratio.

MHTMatrixSortRows

Sort rows in the MHT.

MHTMatrixTreeConvert

Convert to and from a tree format for the MHT data.

MHTTrackMerging

Merge MHT tracks.

MHTTrackMgmt

Manage MHT tracks.

MHTTrackScore

Compute the total score for the track.

MHTTrackScoreKinematic

Compute the kinematic portion of the track score.

MHTTrackScoreSignal

Compute the signal portion of the track score.

MHTTreeDiagram

Draw an MHT tree diagram.

MHTTrkToB

Convert tracks to a B matrix.

PlotTracks

Plot object tracks.

Residual

Compute the residual.

TOMHTTreeAnimation

Track-oriented MHT tree diagram animation.

TOMHTAssignment

Assign a scan to a track.

TOMHTPruneTracks

Prune the tracks.