I am new to PyMC and I am studying the Simpson’s Paradox tutorial. The last line in Models 2 and 3 (cells 12 and 17) is
pm.Normal("y", mu=μ, sigma=sigma[g], observed=data.y, dims="observation")
where sigma
is previously bound to a pm.HalfCauchy
, i.e.,
sigma = pm.HalfCauchy("sigma", beta=2, dims="group")
ad g
to an instance of pm.Data
, i.e.,
g = pm.Data("g", data.group_idx, dims="observation")
I am wondering about the semantics of sigma[g]
. Evidently, __getitem__
has been overridden on pm.HalfCauchy
so that indexing into it with a pm.Data
instance makes sense (note that the result of the indexing operation is an AdvancedSubtensor.0
). But what does such an indexing operation mean in this context, and where might the override be documented? (Please note: I get the impression, from what I have seen in the docs and elsewhere so far, that this pattern of indexing into one PyMC object with another is rare; is my impression correct?).
Thank you very much.