How to create a design of experiments with both continuous and discrete random variables with OpenTURNS?
I get that we can do:
X0 = ot.Normal()
X1 = ot.Normal()
distribution = ot.ComposedDistribution([X0,X1])
But this creates only a continuous joint distribution, from which I can sample from. But how to create a joint distribution of a continuous and a discrete variable? Can I sample from it then?
Actually, in general, OpenTURNS does not make much difference between continuous and discrete distributions. So, once we have created a
Distribution, all we have to do is to use thegetSamplemethod to get a simple Monte-Carlo sample. The following example shows that we can push the idea a little further by creating a LHS design of experiments.To create the first marginal of the distribution, we select a univariate discrete distribution. Many of them, like the
BernoulliorGeometricdistributions, are implemented in the library. In this example we pick theUserDefineddistribution that assigns equal weights to the values -2, -1, 1 and 2. Then we create a Monte-Carlo experiment first with thegetSamplemethod and then with theMonteCarloExperimentmethod. Any other type of design of experiments can be generated based on this distribution and this is why we finally show how to create a LHS (Latin Hypercube) experiment.The following script produces the associated graphics.
The previous script prints:
and produces the following graphics:
It is straightforward to create a LHS on the same distribution.