Open reubenharry opened 1 year ago
@reubenharry I had an idea how to tackle this problem, extending your Bayesian
data structure:
Just at a surface level read, I'm wondering whether the ideas in https://github.com/psg-mit/probzelus-haskell/tree/master/haskell/src are relevant. They are a Haskell port of ideas from the Gen
probabilistic programming language, which also passes along pdfs in order to deal with the Borel conditioning issue, I think in a similar way to what you are suggesting. See in particular Distributions.hs, Metaprob.hs and MetaGen.hs.
Good catch!
This is pretty similar to my idea, but a bit purer even. The rest I must admit I don't fully understand, probably there are some good ideas in there that I can't appreciate yet.
So this turns out to be a common problem in probabilistic programming languages related to Borel's paradox (which is the issue of conditioning on measure-0 sets). If I write:
there's no hope that any inference algorithm will get the true posterior (without doing a source code transformation) because the probability of drawing a given number from a normal (or any continuous distribution) is 0. Instead we could write
This works fine, and should be (modulo typos/thinkos) denotationally equivalent.
My concern about the SoftEq solution is that it distorts the probabilistic program that specifies the posterior (if indeed bayesFilter is used to define the posterior). As you say above, it should not really be in the probabilistic program, but rather in the inference somehow, because otherwise the program ceases to be a correct mathematical description of the posterior (unless we're lucky).
My solution in general has been to avoid doing something like
SoftEq
, and instead specify the model with a data structure like:where
generative
andlikelihood
correspond to the same conditional distribution, but in two forms. The second form is the one used in writingposterior
:which is the non-reactive analog of
bayesFilter
.On the other hand, it's sometimes not possible to give an explicit density for the generative model, so we could offer something like
bayesFilter
as long as it's clear it's not giving the true posterior.