Skip to content

Commit dc65293

Browse files
committed
Small improvements to probability docs
1 parent 51064ee commit dc65293

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

docs/src/tutorials/prob-interface.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,19 @@ nothing # hide
6969
We often want to calculate the (unnormalized) probability density for an event.
7070
This probability might be a prior, a likelihood, or a posterior (joint) density.
7171
DynamicPPL provides convenient functions for this.
72-
For example, we can calculate the joint probability of a set of samples (here drawn from the prior) with [`logjoint`](@ref):
72+
To begin, let's define a model `gdemo`, condition it on a dataset, and draw a sample.
73+
The returned sample only contains `μ`, since the value of `x` has already been fixed:
7374

7475
```@example probinterface
7576
model = gdemo(length(dataset)) | (x=dataset,)
7677
7778
Random.seed!(124)
7879
sample = rand(model)
80+
```
81+
82+
We can then calculate the joint probability of a set of samples (here drawn from the prior) with [`logjoint`](@ref).
83+
84+
```@example probinterface
7985
logjoint(model, sample)
8086
```
8187

@@ -90,7 +96,8 @@ sample_dict = rand(OrderedDict, model)
9096
logjoint(model, sample_dict)
9197
```
9298

93-
The prior probability and the likelihood of a set of samples can be calculated with the functions [`loglikelihood`](@ref) and [`logjoint`](@ref), respectively:
99+
The prior probability and the likelihood of a set of samples can be calculated with the functions [`logprior`](@ref) and [`loglikelihood`](@ref) respectively.
100+
The log joint probability is the sum of these two quantities:
94101

95102
```@example probinterface
96103
logjoint(model, sample) ≈ loglikelihood(model, sample) + logprior(model, sample)

0 commit comments

Comments
 (0)