Skip to content
MthwRobinson edited this page Dec 21, 2014 · 1 revision

Mixing Random Variables

Mixture

Mixture computes the 'mixture' of a list of n random variables. The first argument is a list of weights for the random variables involved. These must sum to one. The second argument is a list of the random variable to be mixed. The distribution is a result of these weighted mixtures.

Syntax

Mixture([p1,p2,...,pn],[X1,X2,..,Xn])

Examples:

In [13]: X1=TriangularRV(Rational(2),Rational(4),Rational(6))

In [14]: X2=TriangularRV(Rational(3),Rational(5),Rational(7))

In [15]: X3=TriangularRV(Rational(1),Rational(5),Rational(9))

In [16]: mixtures=[Rational(1,4),Rational(1,4),Rational(1,2)]

In [17]: Y=Mixture(mixtures,[X1,X2,X3])

In [18]: Y.display()
continuous pdf
for 1 <= x <= 2
---------------------------
x    1 
── - ──
32   32
---------------------------
 
 
for 2 <= x <= 3
---------------------------
3x   5 
─── - ──
 32   32
---------------------------
 
 
for 3 <= x <= 4
---------------------------
5x   11
─── - ──
 32   32
---------------------------
 
 
for 4 <= x <= 5
---------------------------
x    5 
── + ──
32   32
---------------------------
 
 
for 5 <= x <= 6
---------------------------
  5x   35
- ─── + ──
   32   32
---------------------------
 
 
for 6 <= x <= 7
---------------------------
  3x   23
- ─── + ──
   32   32
---------------------------
 
 
for 7 <= x <= 9
---------------------------
  x    9 
- ── + ──
  32   32
---------------------------
Clone this wiki locally