mitchelloharawild/distributional

Inconsistency in vectorisation of multivariate distributions

robjhyndman opened this issue · 3 comments

library(distributional)
mu <- c(0, 0)
Sigma <- diag(2)
dist <- distributional::dist_multivariate_normal(list(mu), list(Sigma))

density(dist, at = c(0,0))
#> [[1]]
#> [1] 0.1591549
density(dist, at = matrix(c(0,0), nrow=1))
#> [1] 0.1591549

Created on 2024-07-31 with reprex v2.1.1

I think the first option here should error, since the dimensions of at do not match the dimension of the distribution. What do you think?

The intended vectorisation is described in #52 (comment), although more formal descriptions of how distributional vectorises distributions/operations is needed (#107).

I was thinking a vector should be interpreted as a 1 row matrix, and then the dimensions do match. This is how mvtnorm::dmvnorm() works.

For me it's a question of if that default mapping of dimensions is appropriate, and I'm leaning toward being strict and not having a default dimension for univariate inputs -> multivariate distributions (essentially requiring matrix inputs)