pyro-ppl / funsor

Functional tensors for probabilistic programming
https://funsor.pyro.ai
Apache License 2.0
236 stars 20 forks source link

Delta integrate pattern #595

Open ordabayevy opened 2 years ago

ordabayevy commented 2 years ago

(Separating this from #593 PR)

This proposes the following logic for the Delta Integrate pattern:

delta = Delta("x",  point, log_density)
integrand = Variable("x")
Integrate(delta, integrand, reduced_vars="x")
  => delta(x=point).exp() * integrand(x=point)
  => log_density.exp() * point

where log_density can be a Dice factor or an importance weight in general.

delta = Delta("x",  point, log_density)
integrand = Number(3.0)
Integrate(delta, integrand, reduced_vars="x")
  => delta.reduce(logaddexp, "x").exp() * integrand
  => 1 * 3.0
  => 3.0

where delta is normalized.