BIFM node
The Backward Information Forward Marginals (BIFM) node implements an efficient Kalman smoothing step for linear Gaussian state-space models. It fuses all factor contributions within a single time slice — observation likelihood, state transition, and the backward information from future time steps — into one node, enabling correct smoothed marginals without a separate backward pass.
Model structure
The BIFM node has four interfaces:
| Interface | Role |
|---|---|
out | Latent output (observation) of the time slice |
in | Latent input to the time slice (e.g., a control signal) |
zprev | Previous latent state zₜ₋₁ |
znext | Next latent state zₜ (carries backward information from future) |
The state-space equations encoded by the node are:
\[z_t = A \, z_{t-1} + B \, u_t, \qquad x_t = C \, z_t\]
where A, B, and C are the transition, input, and output matrices stored in BIFMMeta.
Usage
The BIFM node must be used together with BIFMHelper, which carries backward smoothing information between time steps. A typical model looks like:
z_prior ~ MvNormalMeanPrecision(zeros(latent_dim), diagm(ones(latent_dim)))
z_tmp ~ BIFMHelper(z_prior)
z_prev = z_tmp
for i in 1:nr_samples
u[i] ~ MvNormalMeanPrecision(μu, Wu)
xt[i] ~ BIFM(u[i], z_prev, z[i]) where { meta = BIFMMeta(A, B, C) }
x[i] ~ MvNormalMeanPrecision(xt[i], Wx)
z_prev = z[i]
endWhen subscribing to marginals, subscribe in the order z, out, in before subscribing to the free energy score function. This ordering ensures that the backward information is propagated correctly before the score is evaluated.
Relationship to ContinuousTransition
The ContinuousTransition node encodes a single linear-Gaussian transition y ~ N(K(a)·x, W⁻¹) where the transition matrix can itself be a latent variable. BIFM is a more specialized node: the matrices A, B, C are fixed (passed through meta), but the node efficiently handles the full time-slice factor, including the smoothing backward pass. Use ContinuousTransition when the transition matrix is uncertain and must be inferred; use BIFM when the structure is known and smoothing efficiency matters.
See also the BIFM tutorial in the RxInfer.jl documentation for a comprehensive guide.
ReactiveMP.BIFM — Type
The BIFM node is a node that can be used as a substitution for a state space model. It includes all factor of the time slice to perform efficient inference. This node needs to be used in conjuction with the BIFMHelper node for efficient inference.
out ~ BIFM(in, zprev, znext)Interfaces:
- out - latent output (observation) of the BIFM node
- in - latent input of the BIFM node
- zprev - previous latent state of the BIFM node
- znext - next latent state of the BIFM node
Note: When performing inference, first subscribe to the marginals (in the order: z, out, in) and then to the free energy score function.
Example
# set priors
z_prior ~ MvNormalMeanPrecision(zeros(latent_dim), diagm(ones(latent_dim)))
z_tmp ~ BIFMHelper(z_prior)
# update last/previous hidden state
z_prev = z_tmp
# loop through observations
for i in 1:nr_samples
# specify input as random variable
u[i] ~ MvNormalMeanPrecision(μu, Wu)
# specify observation
xt[i] ~ BIFM(u[i], z_prev, z[i]) where { meta = BIFMMeta(A, B, C) }
x[i] ~ MvNormalMeanPrecision(xt[i], Wx)
# update last/previous hidden state
z_prev = z[i]
endReactiveMP.BIFMMeta — Type
The BIFMMeta structure contains all characterizing information of the BIFM node. In addition, it stores intermediate variables for efficient computations.
ReactiveMP.BIFMHelper — Type
The BIFMHelper node is a node required to perform efficient message passing inconjuction with the BIFM node. It is required to switch from the backward pass with messages to the forward pass with marginals.
out ~ BIFMHelper(in)Interfaces:
- out - output of the BIFMHelper node, should be connected to the state space model.
- in - input of the BIFMHelper node, should be connected to the prior for the latent state.
Note: When performing inference, first subscribe to the marginals (in the order: z, out, in) and then to the free energy score function.