Create a 2-d gaussian distributionΒΆ

In this basic example we are going to create a bidimensional gaussian distribution with parameters

\mu = [0.0, 2.2], \sigma = [1.0, 0.6]

In [1]:
from __future__ import print_function
import openturns as ot
In [2]:
# create the distribution, no correlation
distribution = ot.Normal([0.0, 2.0], [1.0, 0.6], ot.CorrelationMatrix(2))
print(distribution)
Normal(mu = [0,2], sigma = [1,0.6], R = [[ 1 0 ]
 [ 0 1 ]])
In [3]:
# draw a sample
sample = distribution.getSample(10)
print(sample)
    [ X0        X1        ]
0 : [  0.608202  1.2403   ]
1 : [ -0.438266  2.72329  ]
2 : [ -2.18139   2.21003  ]
3 : [ -0.355007  2.86235  ]
4 : [  0.810668  2.47589  ]
5 : [ -0.470526  2.15661  ]
6 : [ -2.29006   1.23027  ]
7 : [ -1.31178   1.94553  ]
8 : [  0.995793  1.91633  ]
9 : [ -0.560206  2.26729  ]
In [4]:
# draw PDF
distribution.drawPDF()
Out[4]:
../../_images/examples_probabilistic_modeling_2d_gaussian_distribution_5_0.svg