You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/using-turing/guide.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -545,6 +545,41 @@ The `Gibbs` sampler can be used to specify unique automatic differentation backe
545
545
546
546
For more details of compositional sampling in Turing.jl, please check the corresponding [paper](http://proceedings.mlr.press/v84/ge18b.html).
547
547
548
+
### Working with filldist and arraydist
549
+
550
+
Turing provides `filldist(dist::Distribution, n::Int)` and `arraydist(dists::AbstractVector{<:Distribution})` as a simplified interface to construct product distributions, e.g., to model a set of variables that share the same structure but vary by group.
551
+
552
+
#### Constructing product distributions with filldist
553
+
554
+
The function `filldist` provides a general interface to construct product distributions over distributions of the same type and parameterisation.
555
+
Note that, in contrast to the product distribution interface provided by Distributions.jl (`Product`), `filldist` supports product distributions over univariate or multivariate distributions.
556
+
557
+
Example usage:
558
+
559
+
```julia
560
+
@modelfunctiondemo(x, g)
561
+
k =length(unique(g))
562
+
a ~filldist(Exponential(), k) # = Product(fill(Exponential(), k))
563
+
mu = a[g]
564
+
x .~Normal.(mu)
565
+
end
566
+
```
567
+
568
+
#### Constructing product distributions with arraydist
569
+
570
+
The function `arraydist` provides a general interface to construct product distributions over distributions of varying type and parameterisation.
571
+
Note that in contrast to the product distribution interface provided by Distributions.jl (`Product`), `arraydist` supports product distributions over univariate or multivariate distributions.
572
+
573
+
Example usage:
574
+
575
+
```julia
576
+
@modelfunctiondemo(x, g)
577
+
k =length(unique(g))
578
+
a ~arraydist([Exponential(i) for i in1:k])
579
+
mu = a[g]
580
+
x .~Normal.(mu)
581
+
end
582
+
```
548
583
549
584
### Working with MCMCChains.jl
550
585
@@ -638,3 +673,4 @@ In all other cases progress logs are displayed with
0 commit comments