Linear & Piecewise Regression
Start simple with Bayesian linear regression, then extend to piecewise models using a Poisson point process.
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).
A Poisson process on , sampled lazily. Each draw becomes a gap .
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)Ready.
Scroll within the table for more values.
Ready.
Scroll within the table for more values.
Ready.
Scroll within the table for more values.
Ready.
Scroll within the table for more values.
Ready.
Scroll within the table for more values.
Laziness lets us specify non-parametric models cleanly: processes or infinite-dimensional functions only have their finite explored portion materialised.
Start simple with Bayesian linear regression, then extend to piecewise models using a Poisson point process.
Model time series with Wiener process priors for continuous, nowhere-differentiable random functions.
Infer arithmetic expressions that explain observed data using probabilistic program induction.
Dirichlet Process mixture models that discover the number of clusters automatically.
LazyPPL provides two monads:
Prob aprobability 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 aunnormalized 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.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)