javaslam.filter
Class KalmanFilter

java.lang.Object
  |
  +--javaslam.filter.KalmanFilter
All Implemented Interfaces:
Filter

public class KalmanFilter
extends Object
implements Filter

A Kalman filter.

This class records counts of all floating point operations using Flops.count(long) (except those used in the service of debugging and avoiding numerical errors).


Field Summary
protected  Gaussian p
          The moment potential representing the belief state.
 
Constructor Summary
KalmanFilter(Gaussian p)
          Constructor.
 
Method Summary
 Gaussian getDistribution()
          Returns the current filtered belief state.
 Gaussian getMarginal(Set vars)
          Extracts the filtered marginal distribution.
 Map getMarginals(Collection vars)
          Extracts a set of unary marginals.
 Set getVariables()
          Gets an unmodifiable set of the Variables in the filtered belief state.
 void joseph(ListSet vars, double[] y0, double[][] C, double[][] R, double[] y)
          Performs a linear-Gaussian measurement update using the Joseph form of the covariance update, which is numerically more stable.
 void marginalizeOut(Set mvars)
          Marginalizes a set of variables out of the belief state.
 void measurement(ListSet vars, double[] y0, double[][] C, double[][] R, double[] y)
          Performs a linear-Gaussian measurement update.
 void time(ListSet vars, double[] x0, double[][] A, double[][] Q)
          Performs a linear-Gaussian time update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

p

protected Gaussian p
The moment potential representing the belief state.

Constructor Detail

KalmanFilter

public KalmanFilter(Gaussian p)
Constructor.

Parameters:
p - the initial belief state
Method Detail

getDistribution

public Gaussian getDistribution()
Returns the current filtered belief state.

Returns:
the current filtered belief state

marginalizeOut

public void marginalizeOut(Set mvars)
Marginalizes a set of variables out of the belief state.

Specified by:
marginalizeOut in interface Filter
Parameters:
mvars - a set of Variables to marginalize out

measurement

public void measurement(ListSet vars,
                        double[] y0,
                        double[][] C,
                        double[][] R,
                        double[] y)
Performs a linear-Gaussian measurement update. The parameters vars, C and R define the measurement equation as follows:
y=y0 + Cx(vars)+w
where w is a white-noise variable with covariance R. Given the actual measurement y, this method updates the belief state.

Specified by:
measurement in interface Filter
Parameters:
vars - an ordered set of the variables with sum dimension n in the belief state that causally influenced this measurement; any variables in this list that are not currently in the belief state are added with uninformative priors.
y0 - a k-vector giving the constant term
C - a k by n observation matrix that defines the linear measurement model (and whose columns are ordered consistently with the order of vars)
R - a k by k symmetric positive definite matrix giving the covariance of the measurement white noise
y - the measurement k-vector
Throws:
IllegalArgumentException - if there are any dimension mismatches

joseph

public void joseph(ListSet vars,
                   double[] y0,
                   double[][] C,
                   double[][] R,
                   double[] y)
Performs a linear-Gaussian measurement update using the Joseph form of the covariance update, which is numerically more stable. The parameters vars, C and R define the measurement equation as follows:
y=y0 + Cx(vars)+w
where w is a white-noise variable with covariance R. Given the actual measurement y, this method updates the belief state.

Parameters:
vars - an ordered set of the variables with sum dimension n in the belief state that causally influenced this measurement; any variables in this list that are not currently in the belief state are added with uninformative priors.
y0 - a k-vector giving the constant term
C - a k by n observation matrix that defines the linear measurement model (and whose columns are ordered consistently with the order of vars)
R - a k by k symmetric positive definite matrix giving the covariance of the measurement white noise
y - the measurement k-vector
Throws:
IllegalArgumentException - if there are any dimension mismatches

time

public void time(ListSet vars,
                 double[] x0,
                 double[][] A,
                 double[][] Q)
Performs a linear-Gaussian time update. The parameters vars, A and Q define the state evolution equation as follows:
xt + 1(vars)=x0 + Axt(vars)+v
where v is a white-noise variable with covariance Q. All variables not in vars are assumed stationary.

Specified by:
time in interface Filter
Parameters:
vars - an ordered set of the variables with sum dimension n in the belief state that evolve over time
x0 - an n-vector giving the constant term
A - an n by n evolution matrix that defines the linear evolution model (and whose blocks are ordered consistently with the order of vars)
Q - an n by n symmetric positive definite matrix giving the covariance of the evolution white noise (and whose blocks are ordered consistently with the order of vars)
Throws:
IllegalArgumentException - if there are any dimension mismatches or vars contains variables that are not in the current belief state

getMarginal

public Gaussian getMarginal(Set vars)
Extracts the filtered marginal distribution.

Specified by:
getMarginal in interface Filter
Parameters:
vars - the set of Variables whose filtered marginal is to be computed
Returns:
a filtered marginal potential over vars

getMarginals

public Map getMarginals(Collection vars)
Extracts a set of unary marginals.

Specified by:
getMarginals in interface Filter
Parameters:
vars - a collection of Variables, or null to indicate all variables in the belief state
Returns:
a map whose keys are the (distinct) elements of vars and whose values are the corresponding marginals (in the moment parameterization)

getVariables

public Set getVariables()
Gets an unmodifiable set of the Variables in the filtered belief state.

Specified by:
getVariables in interface Filter