Statistical programming with categorical measure theory and LazyPPL
Demo
linear :: Prob (Double -> Double)
linear = do
a <- normal 03
b <- normal 03let f = \x -> a * x + b
return f
regress :: Double -> Prob (a -> Double) -> [(a, Double)] -> Meas (a -> Double)
regress σ prior dataset = do
f <- sample prior
mapM_ (\(x, y) -> score $ normalPdf (f x) σ y) dataset
return f
Statistical programming with categorical measure theory and LazyPPL
Semantically
Inference:
pick a parameter p by sampling a point from the area under the curve of the weight function l
use this parameter p to determine a result r(p).
Statistical programming with categorical measure theory and LazyPPL
Problems
Measnot cartesian closed:
no function space like Double -> Double
Not known if there is a strong monad of measures
the category of s-finite kernels is distributive symmetric monoidal
but is it a Kleisli category?
Statistical programming with categorical measure theory and LazyPPL
Inverse Transform Sampling
Noise outsourcing lemma: The law of every Borel-valued random variable can be obtained as a pushforward of the uniform measure [0,1].
Given a parameterized probability distribution k:A→P(B), there is a function f:A×[0,1]→B such that for all a,
k(a)=Df(a,u)where u∼U([0,1])
k(a) = do { u ← uniform 01; return f (a, p)
Statistical programming with categorical measure theory and LazyPPL
Quasi-Borel Spaces
Ω: fixed uncountable standard Borel space
LazyPPL: infinite rose trees, with splitting γ:Ω≅Ω×Ω
quasi-Borel space X: set MX⊆XΩ of random elements
Qbs: cartesian closed, commutative monad of measures
LazyPPL: Prob vs Meas ⟶ two Kleisli categories
Laziness in program evaluation: monoidal category Kl(Prob) has a terminal unit
Statistical programming with categorical measure theory and LazyPPL
Proba and Measure Kernels
Prob: Probability kernels f:X×Ω→Y modulo equivalence
Composition: X×ΩX×γX×Ω×Ωf×ΩY×ΩgZ
Monad on Qbs: X↦XΩ
Meas: Measure kernels [0,∞]lX×ΩfY mod equiv
Composition: compose the proba kernels, multiply the weights
Monad on Qbs: X↦(X×R)Ω
Statistical programming with categorical measure theory and LazyPPL
Correspondence
Proba
Categorical Proba
Prob Prog
Spaces
Objects
Types
Proba kernels
Morphisms
Programs
Fubini’s theorem
Interchange law / Commutativity
Reordering lines
Marginalisation
Semi-cartesianness / Affineness
Discarding / Laziness
Statistical programming with categorical measure theory and LazyPPL