mitchelloharawild / distributional

Vectorised distributions for R
https://pkg.mitchelloharawild.com/distributional
GNU General Public License v3.0
97 stars 15 forks source link

Inconsistency when programmatically create dist_mixture #111

Open statasaurus opened 4 months ago

statasaurus commented 4 months ago

Basically when you try to make a mixture distribution with a vector of distributional objects it doesn't work. The results are very strange. It would be fine if it errored and just said you needed a list.


Brief description of the problem

# This works as I expect it to 
dist_ls <- list(dist_normal(mu = 0, sigma = 1), dist_student_t(df = 10),
                dist_student_t(df = 5))
dist_mixture(!!!dist_ls, 
             weights = c(0.5,0.2, 0.3)) 

# This makes makes a vector named vector where the length and the names match
# the number of parameters in the first distribution. But, each element of the
# vector is what I expect
dist_vec <- c(dist_normal(mu = 0, sigma = 1), dist_student_t(df = 10),
              dist_student_t(df = 5))
dist_mixture(!!!dist_vec, 
             weights = c(0.5,0.2, 0.3))