.. 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_estimate_dependency_and_copulas_plot_estimate_copula.py:
Fit a parametric copula
=======================
In this example we are going to estimate the parameters of a gaussian copula from a sample.
.. code-block:: default
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)
Create data
.. code-block:: default
R = ot.CorrelationMatrix(2)
R[1, 0] = 0.4
copula = ot.NormalCopula(R)
sample = copula.getSample(500)
Estimate a normal copula
.. code-block:: default
distribution = ot.NormalCopulaFactory().build(sample)
print(distribution)
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
NormalCopula(R = [[ 1 0.353186 ]
[ 0.353186 1 ]])
The estimated parameters
.. code-block:: default
distribution.getParameter()
.. raw:: html
[0.353186]
Draw fitted distribution
.. code-block:: default
graph = distribution.drawPDF()
view = viewer.View(graph)
plt.show()
.. image:: /auto_data_analysis/estimate_dependency_and_copulas/images/sphx_glr_plot_estimate_copula_001.png
:alt: [X0,X1] iso-PDF
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.125 seconds)
.. _sphx_glr_download_auto_data_analysis_estimate_dependency_and_copulas_plot_estimate_copula.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_estimate_copula.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_estimate_copula.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_