Skip to content

Commit

Permalink
Added case study on probabilistic programming and inference (#445)
Browse files Browse the repository at this point in the history
Added the case study `Inference` that contains the contents of my
bachelor's thesis `Probabilistic Programming and Programmable Inference
in Effekt`.

The content includes Slice Sampling and Metropolis-Hastings algorithms,
as well as some examples to show how these algorithms can be applied.
  • Loading branch information
dvdvgt authored Sep 17, 2024
2 parents cd18ad8 + 6ee5a42 commit 22ebac2
Show file tree
Hide file tree
Showing 5 changed files with 761 additions and 0 deletions.
4 changes: 4 additions & 0 deletions effekt/jvm/src/test/scala/effekt/ChezSchemeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ abstract class ChezSchemeTests extends EffektTests {
examplesDir / "pos" / "unsafe_cont.effekt",
examplesDir / "pos" / "propagators.effekt",

// the number representations differ in JS and Chez
examplesDir / "casestudies" / "ad.effekt.md",
examplesDir / "casestudies" / "inference.effekt.md",

// in the CallCC variant, we cannot have toplevel vals at the moment (their bindings need to be wrapped in `(run (thunk ...))`
// see comment on commit 61492d9
examplesDir / "casestudies" / "anf.effekt.md",
Expand Down
1 change: 1 addition & 0 deletions effekt/jvm/src/test/scala/effekt/MLTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class MLTests extends EffektTests {
examplesDir / "pos" / "either.effekt",
examplesDir / "pos" / "namespaces.effekt",
examplesDir / "pos" / "exists.effekt", // now show instance for existentials
examplesDir / "casestudies" / "inference.effekt.md",

// polymorphic effect operation not supported
examplesDir / "pos" / "triples.effekt",
Expand Down
58 changes: 58 additions & 0 deletions examples/casestudies/inference.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Point(1.118, -1.718)
Point(1.015, -0.431)
Point(0.951, -0.416)
Point(0.996, 0.143)
Point(0.946, 0.965)
State(1.714, 3.267, 1.714, 0.267)
State(2.218, 5.379, 2.218, 2.379)
State(3.677, 1.218, 3.677, -1.782)
State(2.248, 2.927, 2.248, -0.073)
State(2.764, 1.716, 2.764, -1.284)
Path(
State(0, 3, 2, 0)
State(2.566, 2.16, 2.566, -0.84)
State(5.541, 0.701, 2.975, -1.459)
State(9.763, -2.236, 4.222, -2.938)
State(13.812, -5.436, 4.049, -3.199)
State(17.814, -8.467, 4.002, -3.032)
)
Path(
State(0, 3, 2, 0)
State(1.982, 4.912, 1.982, 1.912)
State(3.768, 5.321, 1.786, 0.409)
State(4.936, 4.639, 1.167, -0.682)
State(6.357, 3.514, 1.422, -1.125)
State(8.397, 1.149, 2.04, -2.365)
)
Path(
State(0, 3, 2, 0)
State(1.421, 3.411, 1.421, 0.411)
State(3.333, 4.189, 1.912, 0.777)
State(4.226, 4.043, 0.893, -0.146)
State(6.99, 3.686, 2.764, -0.357)
State(9.861, 1.338, 2.871, -2.349)
)
Path(
State(0, 3, 2, 0)
State(2.267, 2.841, 2.267, -0.159)
State(4.253, 3.036, 1.987, 0.195)
State(4.665, 3.909, 0.412, 0.873)
State(5.222, 4.47, 0.557, 0.561)
State(5.741, 2.523, 0.519, -1.947)
)
Path(
State(0, 3, 2, 0)
State(0.789, 2.991, 0.789, -0.009)
State(2.336, 2.492, 1.547, -0.499)
State(4.401, 1.887, 2.064, -0.605)
State(7.238, 1.129, 2.838, -0.758)
State(9.284, 0.578, 2.046, -0.551)
)
[
Population(0.7, 0.2, 0.1)
Population(0.346, 0.424, 0.23)
Population(0.163, 0.334, 0.504)
Population(0.086, 0.227, 0.687)
Population(0.04, 0.183, 0.777)
Population(0.038, 0.134, 0.828)
]
Loading

0 comments on commit 22ebac2

Please sign in to comment.