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

Mixtures assume univariate components #121

Open
robjhyndman opened this issue Jul 31, 2024 · 1 comment
Open

Mixtures assume univariate components #121

robjhyndman opened this issue Jul 31, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@robjhyndman
Copy link
Contributor

e.g.,

library(distributional)
p1 <- p2 <- 0.5
mu1 <- c(0, 0)
mu2 <- c(3, 1)
Sigma1 <- rbind(c(1, 0.5), c(0.5, 1))
Sigma2 <- diag(2)
dist_mixture(
  dist_multivariate_normal(list(mu1), list(Sigma1)),
  dist_multivariate_normal(list(mu2), list(Sigma2)),
  weights = c(p1, p2)
) |>
  mean()
#> Error in vapply(x[["dist"]], mean, numeric(1L), ...): values must be length 1,
#>  but FUN(X[[1]]) result is length 2

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

@mitchelloharawild mitchelloharawild added the enhancement New feature or request label Jul 31, 2024
@mitchelloharawild
Copy link
Owner

Implementation of this partly depends on #25, due to the problem being encapsulation of different distribution types.

dim(<dist>) exists to identify the appropriate dimension of the distribution, but is unused (and is not currently easy to use).

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

No branches or pull requests

2 participants