---
title: Transport RJMCMC via Normalizing Flows
url: https://www.emergentmind.com/topics/transport-rjmcmc-via-normalizing-flows
type: topic
---

# Transport RJMCMC via Normalizing Flows

Transport Reversible Jump Markov Chain Monte Carlo (RJMCMC) methods via normalizing flows represent a significant advance for efficient Bayesian model selection and transdimensional inference. These methods utilize deep normalizing flows to construct diffeomorphic transport maps between complex model posteriors and a common reference distribution, enabling near-optimal proposals for dimension-changing jumps in RJMCMC. This approach circumvents the low acceptance rates and poor mixing inherent in classic RJMCMC by transforming transdimensional moves into near-trivial operations under the reference measure, as formalized in the works of Davies et al. [2210.12572] and subsequent extensions [2512.12742].

## 1. Mathematical Structure of Transport RJMCMC

Transport RJMCMC (TRJ) operates on a state space 
$$
\mathcal{X} = \bigcup_{k\in\mathcal{K}} \{ k \} \times \Theta_k,
$$
where each $k$ denotes a discrete model and $\theta_k\in \Theta_k \subset \mathbb{R}^{n_k}$ parameterizes model $k$. The conditional target is $\pi_k(\theta_k) = \pi(k, \theta_k)/\pi(k)$. To facilitate dimension-matching jumps, TRJ constructs for each model $k$ a transport diffeomorphism $T_k: \Theta_k \to \mathbb{R}^{n_k}$ satisfying ideally $T_{k\sharp}\pi_k = \nu^{n_k}$ for a reference (e.g., standard normal) product measure $\nu^{n_k}$.

A transdimensional move from $(k, \theta_k)$ to $(k', \theta_{k'}')$ proceeds by:
1. Mapping $\theta_k$ to the reference $z_k = T_k(\theta_k)$;
2. If $n_{k'} > n_k$, drawing $u \sim \nu^{n_{k'}-n_k}$; if $n_{k'} < n_k$, truncating $z_k$ appropriately;
3. Establishing $z_{k'}$ through a volume-preserving pairing $\bar{h}_{k\rightarrow k'}$, e.g., concatenation or permutation in reference space;
4. Inverting $z_{k'}$ by $\theta_{k'}' = T_{k'}^{-1}(z_{k'})$.

This construction reduces general dimension-changing proposals to invertible, tractable mappings in reference coordinates, leveraging the expressiveness of normalizing flows to approximate the necessary transports [2210.12572, 2512.12742].

## 2. Metropolis–Hastings Acceptance Criteria

The TRJ acceptance probability for a proposed move $(k, \theta_k)\mapsto(k', \theta_{k'}')$ is
$$
\alpha(x, x') = 1 \wedge \frac{\pi(k', \theta_{k'}')}{\pi(k, \theta_k)} \cdot \frac{j_{k'}(k)}{j_k(k')} \cdot \frac{g_u'}{g_u} \cdot \frac{|\det J_{T_k}(\theta_k)|}{|\det J_{T_{k'}}(\theta_{k'}')|},
$$
where $j_k(\cdot)$ is the model-jump proposal probability and $g_u$ (resp. $g_u'$) is the reference density for auxiliary variables $u$ (resp. $u'$).

**Exact Transport Case:**  
If each $T_k$ is an exact transport and the pairing $\bar h$ preserves $\nu$, the acceptance simplifies to
$$
\alpha(x, x') = 1 \wedge \frac{\pi(k')}{\pi(k)} \cdot \frac{j_{k'}(k)}{j_k(k')}.
$$
With $j_k(k') = \pi(k')$, all cross-model moves are accepted ($\alpha \equiv 1$), yielding rejection-free RJMCMC [2210.12572].

**Approximate Flows:**  
Empirically, with trained flows, acceptance rates for cross-model moves typically exceed $70\%$–$90\%$ for expressive architectures such as rational-quadratic masked autoregressive flows (RQMA), far surpassing naive or affine RJMCMC [2210.12572, 2512.12742].

## 3. Architecture and Training of Normalizing Flows

### Flow Parameterization

- **Davies et al. [2210.12572]:**  
  Each $T_k$ is composed as $T_k = h^{-1} \circ F_k \circ h \circ s_k$, where:
    - $s_k(\cdot)$: Affine standardization (empirical mean/variance).
    - $h(\cdot)$: Sigmoid/Logit transforms between $\mathbb{R}^{n_k}$ and $(0,1)^{n_k}$.
    - $F_k$: Stack of three masked-autoregressive spline transforms (RQMA) with rational-quadratic splines (10 bins/11 knots), conditioned by neural networks (two hidden layers, size $32 n_k$).

- **Yin & Jiao [2512.12742]:**  
  Uses RealNVP coupling flows for each model, with "scale" $s$ and "translation" $t$ functions parameterized by neural networks. Flows are either model-specific or amortized via a single conditional network with the model index as context.

### Training Objective

- **Maximum Likelihood:**  
  Train $T_k$ to maximize the expected likelihood of reference samples mapped by $T_k^{-1}$, i.e.,
  $$
  \mathcal{L}(\psi) = \sum_{j=1}^N \log \nu^{n_k}\left( F_k^{-1}(h(s_k(\theta_k^{(j)}))) \right) + \log|\det J_{F_k^{-1}(h(s_k(\theta_k^{(j)})))}|.
  $$

- **Variational Inference (VI):**  
  Yin & Jiao [2512.12742] minimize the reverse KL divergence between the flow-based variational approximation $q_\phi(\theta|k)$ and $p(\theta|k, y)$. Unlike pilot-run-based training, this enables fitting with samples drawn directly from the base distribution, promoting scalability and eschewing expensive MCMC pilot runs.

### Amortized and Conditional Flows

For large or structured model spaces, conditional normalizing flows (CTRJ) are trained to map from a model-and-parameter-augmented reference to any model's parameterization, supporting efficient transport and dramatically reduced training cost [2210.12572, 2512.12742].

## 4. Implementation Workflow and Pseudocode

A schematic pseudocode of the TRJ sampler is as follows:

```
Algorithm TRJ (Transport RJMCMC)
Input: Current state x=(k, θ_k), flows {T_k}, target π, model-jump probs j_k(·), reference ν, within-model reversible kernels P_k(θ,dθ′)
1.  Draw k′ ∼ j_k(·)
2.  If k′ = k:
      Draw θ_k′ ∼ P_k(θ_k, ·) and return (k, θ_k′)
3.  Else (cross-model jump):
      a. Compute z_k = T_k(θ_k)
      b. Set w = n_{k′} − n_k
      c. If w > 0: draw u ~ ν^{w}; z_{k′} = \bar h_{k→k′}(z_k, u)
         If w < 0: (z_{k′}, u) = \bar h_{k→k′}^{-1}(z_k)
         If w = 0: z_{k′} = \bar h_{k→k′}(z_k)
      d. θ_{k′}′ = T_{k′}^{−1}(z_{k′})
      e. Formulate new state x′ = (k′, θ_{k′}′) and compute acceptance α
      f. With probability α, set x ← x′
Return current x
```
[2210.12572, 2512.12742]

## 5. Empirical Performance and Benchmarks

### Experimental Results

- **Sinh–Arcsinh Toy Example:**  
  With known analytic transports, TRJ achieves rejection-free moves. Approximate flows (RQMA or RealNVP) yield nearly the same performance; affine flows result in noticeably worse mixing and slower convergence of model probabilities [2210.12572, 2512.12742].

- **Bayesian Factor Analysis (6×6 covariance):**  
  RQMA-based TRJ greatly outperforms classical Lopes–West proposals and affine flows in mixing and variance reduction (Bartolucci Bridge Estimator), offering lower RMSE in model-probability estimates at fixed computational cost [2210.12572, 2512.12742].

- **Block Variable Selection/Robust Regression:**  
  Standard auxiliary-variable proposals nearly fail to mix between separated modes. Individual (affine/RQMA) flows and conditional flows (CTRJ) both achieve high acceptance and excellent mixing. CTRJ matches the performance of multiple separate flows at much lower training cost [2210.12572, 2512.12742].

- **TRJ-VI-NF Comparisons:**  
  Directly minimizing the reverse KL produces maps that closely approximate the true transport, yielding higher acceptance rates, smaller variance in model probability estimates, and effective sample sizes for between-model jumps 2–3× larger than prior methods [2512.12742].

## 6. Practical Recommendations and Extensions

- **Flow Design:**  
  Choose architectures with analytic invertibility (e.g., RQMA, RealNVP). Use affine flows only when conditional posteriors are close to Gaussian.

- **Preprocessing:**  
  Standardize each training set with elementwise affine transformations computed from pilot samples to improve training efficiency and numerical stability.

- **Data Requirements:**  
  Obtain $10^3$–$10^4$ samples per model for supervised flow training (via MCMC/SMC pilot runs or variational flows, depending on approach).

- **Model Jump Probabilities:**  
  If marginal model probabilities $\pi(k)$ are estimable, use $j_k(k') \approx \pi(k')$ to improve cross-model mixing; otherwise adopt symmetric or local proposals.

- **Marginal-Likelihood Estimation:**  
  Use the tractable flow-based variational densities for efficient estimation of $p(y|k)$ via importance sampling, enabling accurate Bayes-factor computation [2512.12742].

- **Computational Cost:**  
  The up-front cost of flow training is amortized by subsequent orders-of-magnitude speedups in cross-model mixing and typically dwarfed by likelihood evaluations in complex models.

- **Conditional/Amortized Flows:**  
  For large model spaces, employ amortized conditional normalizing flows (CTRJ) for scalability, training on saturated targets that pad all models to $n_{\max}$ dimensions to share statistical strength and training cost across models [2210.12572, 2512.12742].

## 7. Theoretical Foundations and Extensions

“Flows for Flows” [2211.02487] introduces the nested use of normalizing flows, allowing construction of bijective maps between arbitrary distributions with known Jacobians. This principle underpins the design of deterministic RJMCMC proposals via paired flows, extending to settings with both matching and mismatched dimensions by embedding auxiliary variables and constructing invertible mappings on the joint space $(x,u)\leftrightarrow(y,v)$. This framework enables the introduction of optimal transport penalties (e.g., $L_1$, Wasserstein, entropy-regularized cost) to ensure semantically meaningful transports, and supports conditional flows parameterized by model indices or side-information, which can further regularize and scale TRJ to complex, structured model spaces.

The overall methodology centralizes around replacing the design of bespoke, problem-specific RJ proposals with a learned, mathematically principled class of transport maps, ensuring detailed balance via explicit Jacobian accounting and leveraging the full expressive power of modern flow architectures.

---

**References:**  
- Davies, Lucas, Meinshausen, "Transport Reversible Jump Proposals" [2210.12572].  
- Yin, Jiao, "Transport Reversible Jump Markov Chain Monte Carlo with proposals generated by Variational Inference with Normalizing Flows" [2512.12742].  
- Foster, Papamakarios, "Flows for Flows: Training Normalizing Flows Between Arbitrary Distributions with Maximum Likelihood Estimation" [2211.02487].

Source: https://www.emergentmind.com/topics/transport-rjmcmc-via-normalizing-flows