{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Extract the copula from a distribution"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this basic example we are going to retrieve the copula from a multidimensional distribution.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from __future__ import print_function\n",
    "import openturns as ot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Normal(mu = [0,0], sigma = [1,1], R = [[ 1    0.25 ]\n",
      " [ 0.25 1    ]])\n"
     ]
    }
   ],
   "source": [
    "# create a multivariate gaussian distribution\n",
    "mu = [0.0] * 2\n",
    "sigma = [1.0]*2\n",
    "R = ot.CorrelationMatrix(2)\n",
    "R[0, 1] = 0.25\n",
    "distribution = ot.Normal(mu, sigma, R)\n",
    "print(distribution)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NormalCopula(R = [[ 1    0.25 ]\n",
      " [ 0.25 1    ]])\n"
     ]
    }
   ],
   "source": [
    "# extract the copula\n",
    "copula = distribution.getCopula()\n",
    "print(copula)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
