Defining a custom multivariate distribution from univariate distributions and stack

Similar, but it’s the cumulative sum, which in fact mixes information across variables. In that case the logp should actually be summed but PyMC isn’t doing it. We should probably do it though.

In any case you’ll see the logp is basically just requesting the automatic logp and summing the last entries.

In a CustomDist, you could implement the logp as something like…

def logp(value, *params):
  # Recreate the RV
  rv = dist(*params)
  # Request logp
  logp = pm.logp(rv, value)
  # Sum last axis
  return logp.sum(-1)