Skip to contents

A weighted mixture of component distributions, optionally zero-inflated. Mirrors the C# Mixture composite.

Usage

dist_mixture(components, weights, zero_inflated = FALSE, zero_weight = 0)

Arguments

components

a list of corehydro_dist objects, the mixture components.

weights

numeric vector of mixture weights, the same length as components.

zero_inflated

whether the mixture places extra probability mass at zero.

zero_weight

the probability mass at zero when zero_inflated is TRUE; ignored otherwise.

Value

a corehydro_dist of family "Mixture", accepted by every dist_*() verb.

Examples

d <- dist_mixture(
  list(distribution("Normal", c(0, 1)), distribution("Normal", c(5, 1))),
  weights = c(0.5, 0.5)
)
dist_pdf(d, 2.5)
#> [1] 0.0175283