.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_data_analysis/distribution_fitting/plot_model_singular_multivariate_distribution.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_data_analysis_distribution_fitting_plot_model_singular_multivariate_distribution.py: Model a singular multivariate distribution ========================================== .. GENERATED FROM PYTHON SOURCE LINES 7-11 From time to time we need to model singular nD distributions (e.g. the joint distribution of KL coefficients for curves resulting from the transport of a low dimensional random vector). A way to do that is to use an EmpiricalBernsteinCopula with a bin number equal to the sample size (also called the empirical beta copula in this case) .. GENERATED FROM PYTHON SOURCE LINES 11-18 .. code-block:: default import openturns as ot import openturns.viewer as viewer import math as m ot.Log.Show(ot.Log.NONE) ot.RandomGenerator.SetSeed(0) .. GENERATED FROM PYTHON SOURCE LINES 19-20 routine to draw a distribution cloud and a sample .. GENERATED FROM PYTHON SOURCE LINES 20-39 .. code-block:: default def draw(dist, Y): g = ot.Graph() g.setAxes(True) g.setGrid(True) c = ot.Cloud(dist.getSample(10000)) c.setColor("red") c.setPointStyle("bullet") g.add(c) c = ot.Cloud(Y) c.setColor("black") c.setPointStyle("bullet") g.add(c) g.setBoundingBox(ot.Interval( Y.getMin()-0.5*Y.computeRange(), Y.getMax()+0.5*Y.computeRange())) return g .. GENERATED FROM PYTHON SOURCE LINES 40-41 generate some multivariate data to estimate, with correlation .. GENERATED FROM PYTHON SOURCE LINES 41-49 .. code-block:: default f = ot.SymbolicFunction(["U", "xi1", "xi2"], [ "sin(U)/(1+cos(U)^2)+0.05*xi1", "sin(U)*cos(U)/(1+cos(U)^2)+0.05*xi2"]) U = ot.Uniform(-0.85*m.pi, 0.85*m.pi) xi = ot.Normal(2) X = ot.BlockIndependentDistribution([U, xi]) N = 200 Y = f(X.getSample(N)) .. GENERATED FROM PYTHON SOURCE LINES 50-51 estimation by multivariate kernel smoothing .. GENERATED FROM PYTHON SOURCE LINES 51-54 .. code-block:: default multi_ks = ot.KernelSmoothing().build(Y) view = viewer.View(draw(multi_ks, Y)) .. image-sg:: /auto_data_analysis/distribution_fitting/images/sphx_glr_plot_model_singular_multivariate_distribution_001.png :alt: plot model singular multivariate distribution :srcset: /auto_data_analysis/distribution_fitting/images/sphx_glr_plot_model_singular_multivariate_distribution_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 55-56 estimation by empirical beta copula .. GENERATED FROM PYTHON SOURCE LINES 56-63 .. code-block:: default beta_copula = ot.EmpiricalBernsteinCopula(Y, len(Y)) marginals = [ot.KernelSmoothing().build(Y.getMarginal(j)) for j in range(Y.getDimension())] beta_dist = ot.ComposedDistribution(marginals, beta_copula) view = viewer.View(draw(beta_dist, Y)) viewer.View.ShowAll() .. image-sg:: /auto_data_analysis/distribution_fitting/images/sphx_glr_plot_model_singular_multivariate_distribution_002.png :alt: plot model singular multivariate distribution :srcset: /auto_data_analysis/distribution_fitting/images/sphx_glr_plot_model_singular_multivariate_distribution_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.524 seconds) .. _sphx_glr_download_auto_data_analysis_distribution_fitting_plot_model_singular_multivariate_distribution.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_model_singular_multivariate_distribution.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_model_singular_multivariate_distribution.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_