{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# A brief introduction to UQ and SA with the Monte Carlo method\n", "\n", " \n", "**Vinzenz Gregor Eck**, Expert Analytics \n", "\n", " **Leif Rune Hellevik**, NTNU\n", "\n", "\n", "Date: **Jul 13, 2018**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# ipython magic\n", "%matplotlib notebook\n", "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# plot configuration\n", "import matplotlib\n", "import matplotlib.pyplot as plt\n", "plt.style.use(\"ggplot\")\n", "# import seaborn as sns # sets another style\n", "matplotlib.rcParams['lines.linewidth'] = 3\n", "fig_width, fig_height = (7.0,5.0)\n", "matplotlib.rcParams['figure.figsize'] = (fig_width, fig_height)\n", "\n", "# font = {'family' : 'sans-serif',\n", "# 'weight' : 'normal',\n", "# 'size' : 18.0}\n", "# matplotlib.rc('font', **font) # pass in the font dict as kwar" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import chaospy as cp\n", "import monte_carlo\n", "from sensitivity_examples_nonlinear import generate_distributions\n", "from sensitivity_examples_nonlinear import monte_carlo_sens_nonlin\n", "from sensitivity_examples_nonlinear import analytic_sensitivity_coefficients\n", "from sensitivity_examples_nonlinear import polynomial_chaos_sens" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Monte Carlo\n", "\n", "The Monte Carlo method (MCM) is probably the most widely applied method for\n", "variance based uncertainty quantification and sensitivity\n", "analysis. Monte carlo methods are generally straight forward to use\n", "and may be applied to a wide variety of problems as they require few\n", "assumptions about the model or quantity of interest and require no\n", "modifications of the model itself, i.e. the model may be used as a\n", "black box. The basic idea is to calculate statistics (mean, standard\n", "deviation, variance, sobol indices) of $Y$ directly from large amount\n", "of sample evaluations from the black box model $y$.\n", "\n", "\n", "\n", "