# Create a design of experiments with discrete and continuous variables¶

In this example we present how to create a design of experiments when one (or several) of the marginals are discrete.

```from __future__ import print_function
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt
ot.Log.Show(ot.Log.NONE)
```

To create the first marginal of the distribution, we select a univariate discrete distribution. Some of them, like the Bernoulli or Geometric distributions, are implemented in the library as classes. In this example however, we pick the UserDefined distribution that assigns equal weights to the values -2, -1, 1 and 2.

```sample = ot.Sample([[-2.], [-1.], [1.], [2.]])
sample
```
v0 -2 -1 1 2

```X0 = ot.UserDefined(sample)
```

For the second marginal, we pick a Gaussian distribution.

```X1 = ot.Normal()
```

Create the multivariate distribution from its marginals and an independent copula.

```distribution = ot.ComposedDistribution([X0,X1])
```

Create the design.

```size = 100
experiment = ot.MonteCarloExperiment(distribution, size)
sample = experiment.generate()
```

Plot the design.

```graph = ot.Graph("MonteCarloExperiment", "x0", "x1", True, "")
cloud = ot.Cloud(sample, "blue", "fsquare", "")
view = viewer.View(graph)
``` Any other type of design of experiments can be generated based on this distribution. The following example shows a LHS experiment.

```size = 100
alwaysShuffle = True
randomShift = True
experiment = ot.LHSExperiment(distribution, size, alwaysShuffle, randomShift)
sample = experiment.generate()
```
```graph = ot.Graph("LHSExperiment", "x0", "x1", True, "")
cloud = ot.Cloud(sample, "blue", "fsquare", "")
{"ft_lang_label":"__label__en","ft_lang_prob":0.75363755,"math_prob":0.9932379,"size":1831,"snap":"2021-31-2021-39","text_gpt3_token_len":459,"char_repetition_ratio":0.15489875,"word_repetition_ratio":0.07936508,"special_character_ratio":0.25996724,"punctuation_ratio":0.19822486,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9981798,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,1,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-19T09:14:43Z\",\"WARC-Record-ID\":\"<urn:uuid:c538268b-bcff-42f8-adf7-6bf7183fb551>\",\"Content-Length\":\"17870\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:893eeef3-e9ba-4430-b69c-8413e759ef2b>\",\"WARC-Concurrent-To\":\"<urn:uuid:a59dc29e-a9cf-4306-836e-a62d2f33fabc>\",\"WARC-IP-Address\":\"185.199.108.153\",\"WARC-Target-URI\":\"https://openturns.github.io/openturns/1.16/auto_reliability_sensitivity/design_of_experiments/plot_design_of_experiment_continuous_discrete.html\",\"WARC-Payload-Digest\":\"sha1:VVUR4GUBANUSYDLPMYWEU6JZ7X5NVE52\",\"WARC-Block-Digest\":\"sha1:WIIJI23EKV5MYXX33VA43ERGLIETGAJK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780056752.16_warc_CC-MAIN-20210919065755-20210919095755-00392.warc.gz\"}"}