Skip to content

MixtureDistribution ​

The weighted mixture of d1,…,dnd_1, \ldots, d_n with (renormalized) weights w1,…,wnw_1, \ldots, w_n.

MixtureDistribution({w1, ..., wn}, {d1, ..., dn})the weighted mixture of d1, ..., dn; weights are normalized by their sum.
Typed signatures
TypePackageApplies
(list<real>, list<distribution>) -> distributionstatisticsalways

Domain: Statistics

Details
  • Weights are normalized by their sum before use, so {1,1}\{1,1\} and {1,2}\{1,2\}-scaled-by-3 agree.
  • PDF(x)=∑i(wi/∑w)⋅PDF(di,x)PDF(x) = \sum_i (w_i/\sum w) \cdot PDF(d_i,x); CDFCDF the same weighted sum of CDF(di,x)CDF(d_i,x).
  • Mean=∑i(wi/∑w)⋅Mean(di)Mean = \sum_i (w_i/\sum w) \cdot Mean(d_i).
  • VarianceVariance by the law of total variance: ∑iw^i Var(di)+∑iw^i(Mean(di)−Mean)2\sum_i \hat w_i \, Var(d_i) + \sum_i \hat w_i (Mean(d_i) - Mean)^2, where w^i\hat w_i is the normalized weight.
  • RandomVariate picks a component by its normalized weight against one uniform draw, then delegates to RandomVariate on that component — so it reuses whatever per-kind sampler that component already has, old or new, including another compound distribution.

Examples

Basic #
live ↗
Inmean(MixtureDistribution([1,1],[NormalDistribution⁡(0,1),NormalDistribution⁡(10,1)]))\mathrm{mean}(\mathrm{MixtureDistribution}(\bigl\lbrack1, 1\bigr\rbrack, \bigl\lbrack\operatorname{NormalDistribution}(0, 1), \operatorname{NormalDistribution}(10, 1)\bigr\rbrack))Out55
live ↗
InVariance(MixtureDistribution([1,1],[NormalDistribution⁡(0,1),NormalDistribution⁡(10,1)]))\mathrm{Variance}(\mathrm{MixtureDistribution}(\bigl\lbrack1, 1\bigr\rbrack, \bigl\lbrack\operatorname{NormalDistribution}(0, 1), \operatorname{NormalDistribution}(10, 1)\bigr\rbrack))Out2626
live ↗
InN(CDF⁡(MixtureDistribution([1,1],[NormalDistribution⁡(0,1),NormalDistribution⁡(10,1)]),100))N(\operatorname{CDF}(\mathrm{MixtureDistribution}(\bigl\lbrack1, 1\bigr\rbrack, \bigl\lbrack\operatorname{NormalDistribution}(0, 1), \operatorname{NormalDistribution}(10, 1)\bigr\rbrack), 100))Out1.01.0
About
Examples3

See also: TruncatedDistribution, ProductDistribution, RandomVariate