# Create a random mixture of distributions¶

In this example we are going to build an affine combination of input random variables.

This notion is different from the Mixture where the combination is made on the probability density functions and not on the univariate random variable.

In [8]:

from __future__ import print_function
import openturns as ot

In [15]:

# create the distributions associated to the input random variables
X1 = ot.Exponential(1.5)
X2 = ot.Normal(4.0, 1.0)

In [10]:

# offset
a0 = 2.0

In [11]:

# Create the weights
weight = [5.0, 1.0]

In [16]:

# create the affine combination
distribution = ot.RandomMixture([X1, X2], weight, a0)
distribution

Out[16]:


RandomMixture(Normal(mu = 6, sigma = 1) + Exponential(lambda = 0.3, gamma = 0))

In [13]:

# draw PDF
distribution.drawPDF()

Out[13]:

In [14]:

# draw PDF
distribution.drawCDF()

Out[14]: