cscherrer / Soss.jl

Probabilistic programming via source rewriting
https://cscherrer.github.io/Soss.jl/stable/
MIT License
414 stars 30 forks source link

conditional models #216

Closed cscherrer closed 3 years ago

cscherrer commented 3 years ago

WIP-- DO NOT MERGE

Currently we write, e.g.,

dynamicHMC(m(x=x), observations::NamedTuple)

There's an implicit step here of creating the conditional distribution of m(x=x) given observations, but we currently have no way to write this. Also, it would be useful to move closer to Turing's representation for sampling, which doesn't require observations in a separate argument.

At the same time, we need to keep our generative representation. So this is a start on letting us write

m(x=x) | observations

Note that the | here is usually a bitwise or. But I don't see this being used for models, so the overloading feels safe for this usage.

With this change, we now have Model, JointDistribution, and also Conditional. Duplicating methods is starting to seem a bit much. So let's add AbstractModel and define operations on that whenever possible.

For now, we have AbstractModel <: Distribution, but we'll soon move this to <: MeasureTheory.Measure

codecov-io commented 3 years ago

Codecov Report

Merging #216 (6d6ff54) into master (97e49f2) will increase coverage by 2.45%. The diff coverage is 16.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #216      +/-   ##
==========================================
+ Coverage   28.53%   30.99%   +2.45%     
==========================================
  Files          43       45       +2     
  Lines        1265     1381     +116     
==========================================
+ Hits          361      428      +67     
- Misses        904      953      +49     
Impacted Files Coverage Δ
src/core/models/conditional.jl 0.00% <0.00%> (ø)
src/core/models/jointdistribution.jl 21.42% <ø> (ø)
src/core/models/model.jl 77.17% <ø> (ø)
src/core/models/abstractmodel.jl 25.00% <25.00%> (ø)
src/core/toposort.jl 100.00% <100.00%> (ø)
src/particles.jl 14.54% <0.00%> (-1.25%) :arrow_down:
src/core/dependencies.jl 100.00% <0.00%> (ø)
src/transforms/basictransforms.jl 100.00% <0.00%> (ø)
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 97e49f2...6d6ff54. Read the comment docs.