Skip to content

Commit 56087ce

Browse files
authored
Add macroexpand to see the output (#616)
* Add macroexpand to see the output * Add more text
1 parent 7bab552 commit 56087ce

File tree

1 file changed

+12
-1
lines changed
  • developers/compiler/minituring-compiler

1 file changed

+12
-1
lines changed

developers/compiler/minituring-compiler/index.qmd

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,18 @@ We define the probabilistic model:
270270
end;
271271
```
272272

273-
We perform inference with data `x = 3.0`:
273+
The `@mini_model` macro expands this into another function, `m`, which effectively calls either `assume` or `observe` on each variable as needed:
274+
275+
```{julia}
276+
@macroexpand @mini_model function m(x)
277+
a ~ Normal(0.5, 1)
278+
b ~ Normal(a, 2)
279+
x ~ Normal(b, 0.5)
280+
return nothing
281+
end
282+
```
283+
284+
We can use this function to construct the `MiniModel`, and then perform inference with data `x = 3.0`:
274285

275286
```{julia}
276287
sample(MiniModel(m, (x=3.0,)), MHSampler(), 1_000_000; chain_type=Chains, progress=false)

0 commit comments

Comments
 (0)