Given m matrix distributions distributions of length N, creates a new Matdist by summing over the weighted cdfs. Note that this method does not create a MixtureDistribution but a new Matdist. Assumes Matrix distributions have the same number of columns, otherwise use mixturiseVector(lapply(mds, as.VectorDistribution)).

mixMatrix(mds, weights = "uniform")

Arguments

mds

(list())
List of Matdist or Arrdists, should have same number of rows and columns.

weights

(character(1)|numeric())
Individual distribution weights. Default uniform weighting ("uniform").

Details

This method returns a new Matdist which is less flexible than a MixtureDistribution which has parameters (i.e. weights) that can be updated after construction. Also works for Arrdists, where we convert these to Matdists, based on the which.curve initialization parameter.

See also

Examples

m1 <- as.Distribution(
 t(apply(matrix(runif(25), 5, 5, FALSE,
                 list(NULL, 1:5)), 1,
         function(x) x / sum(x))),
 fun = "pdf"
)
m2 <- as.Distribution(
 t(apply(matrix(runif(25), 5, 5, FALSE,
                 list(NULL, 1:5)), 1,
         function(x) x / sum(x))),
 fun = "pdf"
)
# uniform mixing
m3 <- mixMatrix(list(m1, m2))

# un-uniform mixing
m4 <- mixMatrix(list(m1, m2), weights = c(0.1, 0.9))

m1$cdf(3)
#>        [,1]      [,2]      [,3]      [,4]      [,5]
#> 3 0.6998555 0.4082011 0.7042785 0.6939649 0.6087956
m2$cdf(3)
#>       [,1]      [,2]      [,3]      [,4]      [,5]
#> 3 0.508945 0.6287211 0.4297181 0.5005523 0.5717845
m3$cdf(3)
#>        [,1]      [,2]      [,3]      [,4]    [,5]
#> 3 0.6044002 0.5184611 0.5669983 0.5972586 0.59029
m4$cdf(3)
#>       [,1]      [,2]      [,3]      [,4]      [,5]
#> 3 0.528036 0.6066691 0.4571742 0.5198936 0.5754856