1import openturns as ot 2from matplotlib import pyplot as plt 3from openturns.viewer import View 4ot.RandomGenerator.SetSeed(0) 5 6# Generate sample with the given plane 7distribution = ot.ComposedDistribution([ot.Uniform(0, 1)] * 2) 8size = 10 9weightingDistribution = ot.ComposedDistribution([ot.Uniform(0, 1)] * 2) 10experiment = ot.ImportanceSamplingExperiment( 11 distribution, weightingDistribution, size) 12sample = experiment.generate() 13 14# Create an empty graph 15graph = ot.Graph("Importance sampling experiment", "x1", "x2", True, "") 16 17# Create the cloud 18cloud = ot.Cloud(sample, "blue", "fsquare", "") 19 20# Then, draw it 21graph.add(cloud) 22 23fig = plt.figure(figsize=(4, 4)) 24axis = fig.add_subplot(111) 25axis.set_xlim(auto=True) 26View(graph, figure=fig, axes=[axis], add_legend=False) 27