MMAE Filter Bank

needs documentation….


from filterpy.kalman import MMAEFilterBank

pos, zs = generate_data(120, noise_factor=0.2)
z_xs = zs[:, 0]
t = np.arange(0, len(z_xs) * dt, dt)

dt = 0.1
filters = [make_cv_filter(dt), make_ca_filter(dt)]
H_cv = np.array([[1., 0, 0],
                 [0., 1, 0]])

H_ca = np.array([[1., 0., 0.],
                 [0., 1., 0.],
                 [0., 0., 1.]])

bank = MMAEFilterBank(filters, (0.5, 0.5), dim_x=3, H=(H_cv, H_ca))

xs, probs = [], []
for z in z_xs:


Copyright 2015 Roger R Labbe Jr.

FilterPy library.

Documentation at:

Supporting book at:

This is licensed under an MIT license. See the readme.MD file for more information.

class filterpy.kalman.MMAEFilterBank(filters, p, dim_x, H=None)[source]

Implements the fixed Multiple Model Adaptive Estimator (MMAE). This is a bank of independent Kalman filters. This estimator computes the likelihood that each filter is the correct one, and blends their state estimates weighted by their likelihood to produce the state estimate.

filters : list of Kalman filters

List of Kalman filters.

p : list-like of floats

Initial probability that each filter is the correct one. In general you’d probably set each element to 1./len(p).

dim_x : float

number of random variables in the state X

H : Measurement matrix


Zarchan and Musoff. “Fundamentals of Kalman filtering: A Practical Approach.” AIAA, third edition.



ca = make_ca_filter(dt, noise_factor=0.6) cv = make_ca_filter(dt, noise_factor=0.6) cv.F[:,2] = 0 # remove acceleration term cv.P[2,2] = 0 cv.Q[2,2] = 0

filters = [cv, ca] bank = MMAEFilterBank(filters, p=(0.5, 0.5), dim_x=3)

for z in zs:
bank.predict() bank.update(z)

Also, see my book Kalman and Bayesian Filters in Python

x : numpy.array(dim_x, 1)

Current state estimate. Any call to update() or predict() updates this variable.

P : numpy.array(dim_x, dim_x)

Current state covariance matrix. Any call to update() or predict() updates this variable.

x_prior : numpy.array(dim_x, 1)

Prior (predicted) state estimate. The *_prior and *_post attributes are for convienence; they store the prior and posterior of the current epoch. Read Only.

P_prior : numpy.array(dim_x, dim_x)

Prior (predicted) state covariance matrix. Read Only.

x_post : numpy.array(dim_x, 1)

Posterior (updated) state estimate. Read Only.

P_post : numpy.array(dim_x, dim_x)

Posterior (updated) state covariance matrix. Read Only.

z : ndarray

Last measurement used in update(). Read only.

filters : list of Kalman filters

List of Kalman filters.

__init__(filters, p, dim_x, H=None)[source]

x.__init__(…) initializes x; see help(type(x)) for signature


Predict next position using the Kalman filter state propagation equations for each filter in the bank.

u : np.array

Optional control vector. If non-zero, it is multiplied by B to create the control input into the system.

update(z, R=None, H=None)[source]

Add a new measurement (z) to the Kalman filter. If z is None, nothing is changed.

z : np.array

measurement for this update.

R : np.array, scalar, or None

Optionally provide R to override the measurement noise for this one call, otherwise self.R will be used.

H : np.array, or None

Optionally provide H to override the measurement function for this one call, otherwise self.H will be used.