Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency in vectorisation of multivariate distributions #119

Open
robjhyndman opened this issue Jul 31, 2024 · 3 comments
Open

Inconsistency in vectorisation of multivariate distributions #119

robjhyndman opened this issue Jul 31, 2024 · 3 comments

Comments

@robjhyndman
Copy link
Contributor

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

@mitchelloharawild mitchelloharawild changed the title Inconsistent return class from density Inconsistency in vectorisation of multivariate distributions Jul 31, 2024
@mitchelloharawild
Copy link
Owner

mitchelloharawild commented Jul 31, 2024

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).

@robjhyndman
Copy link
Contributor Author

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.

@mitchelloharawild
Copy link
Owner

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants