Skip to content

Commit 359bc31

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

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

docs/src/tutorials/prob-interface.md

Lines changed: 14 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

@@ -87,10 +93,16 @@ using DataStructures
8793
8894
Random.seed!(124)
8995
sample_dict = rand(OrderedDict, model)
96+
```
97+
98+
`logjoint` can also be used on this sample:
99+
100+
```@example probinterface
90101
logjoint(model, sample_dict)
91102
```
92103

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

95107
```@example probinterface
96108
logjoint(model, sample) ≈ loglikelihood(model, sample) + logprior(model, sample)

0 commit comments

Comments
 (0)