mixture: Construct a mixture distribution.

View source: R/mixture.R

mixtureR Documentation

Construct a mixture distribution.

Description

Creates an S3 object representing a finite mixture distribution. The density is f(x) = \sum_{k=1}^{K} w_k f_k(x) where f_k are the component densities and w_k are the mixing weights.

Usage

mixture(components, weights)

Arguments

components

A non-empty list of dist objects.

weights

A numeric vector of non-negative mixing weights that sum to 1 (within tolerance 1e-10). Must have the same length as components.

Details

The class hierarchy is determined by the components: if all components are univariate (or multivariate, continuous, discrete), the mixture inherits those classes as well.

Value

A mixture object with appropriate class hierarchy.

Examples

m <- mixture(
  components = list(normal(0, 1), normal(5, 2)),
  weights = c(0.3, 0.7)
)
mean(m)
vcov(m)
format(m)

algebraic.dist documentation built on Feb. 27, 2026, 5:06 p.m.