Skip to content

Add Index variable to documentation #1422

@alecloudenback

Description

@alecloudenback

I asked on Slack how to do an index variable and @trappmartin responded with the example below. I'd like to contribute some documentation to make this more discoverable. Would the Advanced Usage page be a good place for this?

Do you want something like this: ??
x = vcat(randn(10), randn(10).+10);
g = vcat(ones(Int, 10), ones(Int, 10)*2);
@model function demo(x, g)
  a ~ filldist(Normal(), length(unique(g)))
  mu = a[g]
  x .~ Normal.(mu)
end
model = demo(x,g);
sample(model, NUTS(0.8), 1_000)
Summary Statistics
  parameters     mean     std  naive_se    mcse       ess   r_hat
  ──────────  ───────  ──────  ────────  ──────  ────────  ──────
        a[1]  -0.1021  0.3023    0.0135  0.0105  412.2785  0.9981
        a[2]   9.0334  0.3008    0.0135  0.0267  357.4357  0.9985

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions