funsor
funsor copied to clipboard
Add mixed discrete-continuous examples from "Discrete-Continuous Mixtures in Probabilistic Programming"
~~Blocked for now by #51~~ We may also need a TruncatedNormal
distribution.
This issue proposes to add versions of the examples in section 6 from Discrete-Continuous Mixtures in Probabilistic Programming: Generalized Semantics and Inference Algorithms (Wu et al. 2018)
- [ ] GPA
- [ ] Scale
- [ ] Aircraft tracking
@martinjankowiak as we discussed today, Funsor is currently incorrect when evaluating discrete+continuous mixtures. One possible solution path is to generalize log density to nonstandard reals, either by an Infinite
funsor or by adding funsor metadata in the form of an integer attribute .order
that propagates up to enclosing funsors. Semantically, only the highest-order terms are maintained. This .order
can be seen as the power of the unit infinite number in nonstandard analysis.
On further thought, I believe we could implement this as metadata on each funsor (similar to .bound
and .fresh
) consisting of bounds on the order of infinity, a tuple of integers .order = (lb, ub)
. This propagates up. Tensor
and Gaussian
will satisfy ub = lb
; Delta
will satisfy ub = lb + point.output.num_elements
since it is unknown whether the value is on- or off-peak. Compound funsors will propagate bounds to the top of the ast, thus decisions can be made such as:
@eager.register(Binary, LogaddexpOp, Funsor, Funsor)
def eager_mix_dominate(op, lhs, rhs):
if lhs.order.ub < rhs.order.lb:
return rhs # rhs dominates
if rhs.order.ub < lhs.order.lb:
return lhs # lhs dominates
return None # defer to default implementation