Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/src/using-turing/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,19 @@ The `Gibbs` sampler can be used to specify unique automatic differentation backe

For more details of compositional sampling in Turing.jl, please check the corresponding [paper](http://proceedings.mlr.press/v84/ge18b.html).

### Indexed Group Variables

The function `filldist(distribution,n)` provides a simplified interface for defining a set of model variables that share the same structure, but vary by group.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be formulated in a different way? IMO it sounded a bit like filldist is designed specifically for this purpose, even though that's not the case and it is just a general way of creating a product distribution, in which all single distributions are the same and that allows also multivariate distributions (in contrast to Product in Distributions).

It would be good to mention arraydist as well in case they not all share the same structure.

Maybe something like, "if you want to model a set of variables that share the same structure but vary by group, you can use filldist and arraydist."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree. Maybe there could be two examples, one with and one without filldist or arraydist?


For example, with in the following model ``x ~ Normal(\mu_i)`` where ``\mu_i ~ Normal()`` for each group. The group should be a numeric index.

```julia
@model function demo(x, g)
a ~ filldist(Normal(), length(unique(g)))
mu = a[g]
x .~ Normal.(mu)
end
```

### Working with MCMCChains.jl

Expand Down