mixMatrix: Mix Matrix Distributions into a new Matdist

View source: R/mixMatrix.R

mixMatrixR Documentation

Mix Matrix Distributions into a new Matdist

Description

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

Usage

mixMatrix(mds, weights = "uniform")

Arguments

mds

(list())
List of Matdists, 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.

See Also

mixturiseVector

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)
m2$cdf(3)
m3$cdf(3)
m4$cdf(3)


distr6 documentation built on March 28, 2022, 1:05 a.m.