{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Draw 1-d distribution graphs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this example we are going to draw PDF and CDF of an unidimensional distribution."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Gumbel(alpha = 2.2, beta = 0.6)\n"
]
}
],
"source": [
"from __future__ import print_function\n",
"import openturns as ot\n",
"\n",
"# assume an 1-d distribution\n",
"distribution = ot.Gumbel(0.45, 0.6)\n",
"print(distribution)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
"class=Graph name=X0 PDF implementation=class=GraphImplementation name=X0 PDF title=X0 PDF xTitle=X0 yTitle=PDF axes=ON grid=ON legendposition=topright legendFontSize=1 drawables=[class=Drawable name=Unnamed implementation=class=Curve name=Unnamed derived from class=DrawableImplementation name=Unnamed legend=X0 PDF data=class=Sample name=Unnamed implementation=class=SampleImplementation name=Unnamed size=129 dimension=2 data=[[-1.1431,8.06165e-19],[-1.11169,1.65474e-17],[-1.08027,2.76313e-16],[-1.04886,3.80557e-15],[-1.01744,4.37899e-14],[-0.98603,4.26065e-13],[-0.954616,3.54479e-12],[-0.923202,2.54835e-11],[-0.891787,1.59851e-10],[-0.860373,8.82911e-10],[-0.828959,4.33063e-09],[-0.797544,1.90135e-08],[-0.76613,7.52774e-08],[-0.734716,2.70618e-07],[-0.703301,8.89069e-07],[-0.671887,2.68543e-06],[-0.640473,7.49948e-06],[-0.609058,1.94652e-05],[-0.577644,4.7187e-05],[-0.54623,0.000107325],[-0.514815,0.000230008],[-0.483401,0.000466311],[-0.451987,0.000897652],[-0.420573,0.00164643],[-0.389158,0.00288656],[-0.357744,0.00485212],[-0.32633,0.00784181],[-0.294915,0.0122173],[-0.263501,0.0183938],[-0.232087,0.0268223],[-0.200672,0.0379645],[-0.169258,0.0522612],[-0.137844,0.0700983],[-0.106429,0.0917731],[-0.075015,0.117464],[-0.0436007,0.147209],[-0.0121864,0.180889],[0.0192279,0.218228],[0.0506423,0.258799],[0.0820566,0.30204],[0.113471,0.347281],[0.144885,0.393774],[0.1763,0.440721],[0.207714,0.487315],[0.239128,0.532767],[0.270542,0.576334],[0.301957,0.617344],[0.333371,0.655213],[0.364785,0.689457],[0.3962,0.719697],[0.427614,0.745664],[0.459028,0.767192],[0.490443,0.784216],[0.521857,0.796758],[0.553271,0.80492],[0.584686,0.80887],[0.6161,0.808833],[0.647514,0.805074],[0.678929,0.797892],[0.710343,0.787603],[0.741757,0.774538],[0.773172,0.75903],[0.804586,0.741409],[0.836,0.721993],[0.867415,0.70109],[0.898829,0.678989],[0.930243,0.655957],[0.961657,0.632245],[0.993072,0.608077],[1.02449,0.583657],[1.0559,0.559166],[1.08731,0.534766],[1.11873,0.510594],[1.15014,0.486771],[1.18156,0.463399],[1.21297,0.440564],[1.24439,0.418334],[1.2758,0.396766],[1.30721,0.375904],[1.33863,0.35578],[1.37004,0.336417],[1.40146,0.317828],[1.43287,0.300021],[1.46429,0.282994],[1.4957,0.266744],[1.52712,0.251259],[1.55853,0.236526],[1.58994,0.222528],[1.62136,0.209245],[1.65277,0.196656],[1.68419,0.184737],[1.7156,0.173464],[1.74702,0.162812],[1.77843,0.152755],[1.80984,0.143269],[1.84126,0.134327],[1.87267,0.125903],[1.90409,0.117974],[1.9355,0.110514],[1.96692,0.1035],[1.99833,0.0969076],[2.02974,0.0907154],[2.06116,0.0849014],[2.09257,0.0794447],[2.12399,0.0743255],[2.1554,0.0695244],[2.18682,0.0650234],[2.21823,0.0608049],[2.24964,0.0568524],[2.28106,0.05315],[2.31247,0.0496829],[2.34389,0.0464368],[2.3753,0.0433983],[2.40672,0.0405548],[2.43813,0.0378941],[2.46954,0.0354051],[2.50096,0.0330769],[2.53237,0.0308996],[2.56379,0.0288637],[2.5952,0.0269602],[2.62662,0.0251807],[2.65803,0.0235174],[2.68944,0.0219628],[2.72086,0.02051],[2.75227,0.0191524],[2.78369,0.0178839],[2.8151,0.0166988],[2.84652,0.0155917],[2.87793,0.0145575]] color=red fillStyle=solid lineStyle=solid pointStyle=none lineWidth=2]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# draw PDF\n",
"distribution.drawPDF()\n",
"# IMPORTANT: note that this command just generates the graph data\n",
"# and is only drawn in the context of Jupyter notebooks.\n",
"# To plot from a script, see the viewer module."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
"class=Graph name=X0 CDF implementation=class=GraphImplementation name=X0 CDF title=X0 CDF xTitle=X0 yTitle=CDF axes=ON grid=ON legendposition=topleft legendFontSize=1 drawables=[class=Drawable name=Unnamed implementation=class=Curve name=Unnamed derived from class=DrawableImplementation name=Unnamed legend=X0 CDF data=class=Sample name=Unnamed implementation=class=SampleImplementation name=Unnamed size=129 dimension=2 data=[[-1.1431,7.91695e-21],[-1.11169,1.74132e-19],[-1.08027,3.11576e-18],[-1.04886,4.59831e-17],[-1.01744,5.66979e-16],[-0.98603,5.91132e-15],[-0.954616,5.27004e-14],[-0.923202,4.05972e-13],[-0.891787,2.72878e-12],[-0.860373,1.61504e-11],[-0.828959,8.48855e-11],[-0.797544,3.99355e-10],[-0.76613,1.69424e-09],[-0.734716,6.52652e-09],[-0.703301,2.29761e-08],[-0.671887,7.43652e-08],[-0.640473,2.22537e-07],[-0.609058,6.18934e-07],[-0.577644,1.60776e-06],[-0.54623,3.91846e-06],[-0.514815,8.99856e-06],[-0.483401,1.95488e-05],[-0.451987,4.03243e-05],[-0.420573,7.9253e-05],[-0.389158,0.000148891],[-0.357744,0.000268185],[-0.32633,0.000464445],[-0.294915,0.000775367],[-0.263501,0.00125089],[-0.232087,0.0019546],[-0.200672,0.00296452],[-0.169258,0.00437291],[-0.137844,0.00628512],[-0.106429,0.00881732],[-0.075015,0.0120932],[-0.0436007,0.0162399],[-0.0121864,0.0213834],[0.0192279,0.0276433],[0.0506423,0.0351282],[0.0820566,0.0439313],[0.113471,0.054126],[0.144885,0.0657636],[0.1763,0.078871],[0.207714,0.0934498],[0.239128,0.109476],[0.270542,0.126903],[0.301957,0.14566],[0.333371,0.165657],[0.364785,0.186788],[0.3962,0.208933],[0.427614,0.231961],[0.459028,0.255735],[0.490443,0.280115],[0.521857,0.304959],[0.553271,0.330129],[0.584686,0.355487],[0.6161,0.380907],[0.647514,0.406266],[0.678929,0.431453],[0.710343,0.456364],[0.741757,0.480908],[0.773172,0.505002],[0.804586,0.528575],[0.836,0.551565],[0.867415,0.573921],[0.898829,0.595601],[0.930243,0.616571],[0.961657,0.636807],[0.993072,0.656289],[1.02449,0.675009],[1.0559,0.692959],[1.08731,0.710141],[1.11873,0.72656],[1.15014,0.742225],[1.18156,0.757148],[1.21297,0.771345],[1.24439,0.784834],[1.2758,0.797635],[1.30721,0.80977],[1.33863,0.821261],[1.37004,0.832131],[1.40146,0.842405],[1.43287,0.852108],[1.46429,0.861263],[1.4957,0.869896],[1.52712,0.878031],[1.55853,0.88569],[1.58994,0.892899],[1.62136,0.899679],[1.65277,0.906053],[1.68419,0.912042],[1.7156,0.917666],[1.74702,0.922947],[1.77843,0.927902],[1.80984,0.93255],[1.84126,0.936909],[1.87267,0.940995],[1.90409,0.944824],[1.9355,0.948412],[1.96692,0.951773],[1.99833,0.954919],[2.02974,0.957865],[2.06116,0.960623],[2.09257,0.963203],[2.12399,0.965618],[2.1554,0.967876],[2.18682,0.969989],[2.21823,0.971965],[2.24964,0.973812],[2.28106,0.975539],[2.31247,0.977154],[2.34389,0.978663],[2.3753,0.980074],[2.40672,0.981392],[2.43813,0.982624],[2.46954,0.983774],[2.50096,0.98485],[2.53237,0.985854],[2.56379,0.986793],[2.5952,0.987669],[2.62662,0.988488],[2.65803,0.989252],[2.68944,0.989966],[2.72086,0.990633],[2.75227,0.991256],[2.78369,0.991838],[2.8151,0.992381],[2.84652,0.992888],[2.87793,0.993361]] color=red fillStyle=solid lineStyle=solid pointStyle=none lineWidth=2]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# draw CDF\n",
"distribution.drawCDF()"
]
}
],
"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
}