SMC samplers for binary spaces.


This module implements SMC tempering samplers for target distributions defined with respect to a binary space, {0, 1}^d. This is based on Schäfer & Chopin (2014). Note however the version here also implements the waste-free version of these SMC samplers, see Dang & Chopin (2020).

This module builds on the smc_samplers module. The general idea is that the N particles are represented by a (N, d) boolean numpy array, and the different components of the SMC sampler (e.g. the MCMC steps) operate on such arrays.

More precisely, this module implements:

  • NestedLogistic: the proposal distribution used in Schäfer and Chopin (2014), which amounts to fit a logistic regression to each component i, based on the (i-1) previous components. This is a sub-class of distributions.DiscreteDist.

  • BinaryMetropolis: Independent Metropolis step based on a NestedLogistic proposal. This is a sub-class of smc_samplers.ArrayMetropolis.

  • Various sub-classes of smc_samplers.StaticModel that implements Bayesian variable selection.

See also the scripts in papers/binarySMC for numerical experiments.


  • Dau, H. D., & Chopin, N. (2022). Waste-free sequential Monte Carlo. Journal of the Royal Statistical Society Series B: Statistical Methodology, 84(1), 114-148.

  • Schäfer, C., & Chopin, N. (2013). Sequential Monte Carlo on large binary sampling spaces. Statistics and Computing, 23, 163-184.



chol_and_friends(gamma, xtx, xty, vm2)

corr_bin(pi, pj, pij)

jitted_chol_and_fr(gamma, xtx, xty, vm2)


log without the warning about x <= 0.


BIC([data, lamb])

Likelihood is exp{ - lambda * BIC(gamma)}

BayesianVS([data, prior, nu, lamb, iv2, jitted])

Marginal likelihood for the following hierarchical model: Y = X beta + noise noise ~ N(0, sigma^2) sigma^2 ~ IG(nu / 2, lambda*nu / 2) beta | sigma^2 ~ N(0, v2 sigma^2 I_p)

BayesianVS_gprior([data, prior, nu, lamb, ...])

Same model as parent class, except: beta | sigma^2 ~ N(0, g sigma^2 (X'X)^-1)



NestedLogistic(coeffs, edgy)

Nested logistic proposal distribution.


Meta-class for variable selection.