Laziness for Bayesian nonparametrics.

LazyPPL is a Haskell library for Bayesian probabilistic programming.

It supports lazy use of probability, and we provide new Metropolis-Hastings algorithms to allow this.

LazyPPL is inspired by recent ideas in synthetic probability theory and synthetic measure theory, such as quasi-Borel spaces and Markov categories. Laziness appears to be a good paradigm for non-parametric statistics.

LazyPPL is inspired by many other languages, including Church, Anglican, and MonadBayes. Several aspects are now incorporated into MonadBayes (see here).

01∞

A Poisson process on , sampled lazily. Each draw becomes a gap .

Haskell source

Haskell
splice :: Prob [Double] -> Prob (Double -> Double) -> Prob (Double -> Double)splice pointProcess randomFun =  do    xs <- pointProcess    fs <- mapM (const randomFun) xs    default_f <- randomFun    let h :: [(Double, Double -> Double)] -> Double -> Double        h [] x = default_f x        h ((a, f) : xfs) x | x <= a = f x        h ((a, f) : xfs) x | x > a = h xfs x    return (h (zip xs fs))poissonPP :: Double -> Double -> Prob [Double]poissonPP lower rate =  do    step <- exponential rate    let x = lower + step    xs <- poissonPP x rate    return (x : xs)regress 0.1 (splice (poissonPP 0 0.1) linear)

Piecewise linear regression

Posterior functions
Ready.
Piecewise posterior functions and observationsRun regression to draw piecewise linear posterior functions.
  • log-likelihood low high
  • Observations
Numerical results

Worked examples

All examples

Laziness lets us specify non-parametric models cleanly: processes or infinite-dimensional functions only have their finite explored portion materialised.

Posterior piecewise regression functions and observations.Posterior piecewise regression functions and observations.

Linear & Piecewise Regression

Start simple with Bayesian linear regression, then extend to piecewise models using a Poisson point process.

View readable plot
Posterior Wiener-process functions and observations.Posterior Wiener-process functions and observations.

Wiener Process Regression

Model time series with Wiener process priors for continuous, nowhere-differentiable random functions.

View readable plot
Three inferred program curves and the observations they explain.Three inferred program curves and the observations they explain.
Programs
  • 1
  • 2
  • 3

Program Induction

Infer arithmetic expressions that explain observed data using probabilistic program induction.

View readable plot
Observations assigned to numbered clusters over their inferred densities.Observations assigned to numbered clusters over their inferred densities.
Clusters
  • Cluster 1
  • Cluster 2

Non-parametric Clustering

Dirichlet Process mixture models that discover the number of clusters automatically.

View readable plot

Two-Monad Architecture

LazyPPL provides two monads:

  • Prob a

    probability measures, supporting probability measures such as uniform :: Prob Double, normal :: Double -> Double -> Prob Double, bernoulli :: Double -> Prob Bool. This is lazy, in other words it is an affine monad.

  • Meas a

    unnormalized measures, as used in Monte Carlo simulations for Bayesian statistics. There are two key functions:

    • sample :: Prob a -> Meas a, which samples from a probability measure;
    • score :: Double -> Meas (), which weights a measure by a given value, typically coming from a likelihood function.