Create a mixture of PDFsΒΆ

In this example we are going to build a distribution whose PDF is defined by a linear combination of probability density functions:

f(x) =  \sum_{i=1}^N \alpha_i p_i(x), \quad \alpha_i \geq 0, \quad \sum_i \alpha_i = 1

The weigths are automatically normalized.

It is also possible to create a mixture of copulas.

In [12]:
from __future__ import print_function
import openturns as ot
In [13]:
# create a collection of distribution and the associated weights
distributions = [ot.Triangular(1.0, 2.0, 4.0), ot.Normal(-1.0, 1.0), ot.Uniform(5.0, 6.0)]
weights = [0.4, 1.0, 0.2]
In [14]:
# create the mixture
distribution = ot.Mixture(distributions, weights)
print(distribution)
Mixture((w = 0.25, d = Triangular(a = 1, m = 2, b = 4)), (w = 0.625, d = Normal(mu = -1, sigma = 1)), (w = 0.125, d = Uniform(a = 5, b = 6)))
In [15]:
# draw PDF
distribution.drawPDF()
Out[15]:
../../_images/examples_probabilistic_modeling_mixture_distribution_5_0.svg
In [16]:
# define a list of copulas and the associated weights
copulas = [ot.GumbelCopula(4.5), ot.ClaytonCopula(2.3)]
weights = [0.2, 0.8]
In [17]:
# create a mixture of copulas
distribution = ot.Mixture(copulas, weights)
print(distribution)
Mixture((w = 0.2, d = GumbelCopula(theta = 4.5)), (w = 0.8, d = ClaytonCopula(theta = 2.3)))
In [18]:
# draw PDF
distribution.drawPDF()
Out[18]:
../../_images/examples_probabilistic_modeling_mixture_distribution_8_0.svg