Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"###### Content created under Creative Commons Attribution license CC-BY 4.0, code under BSD 3-Clause License © 2020 R.C. Cooper"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Statistics and Monte-Carlo Models\n",
"\n",
"Monte Carlo models use random numbers to either understand statistics or generate a solution [1]. \n",
"The main element in a Monte Carlo model is the use of random numbers. Monte Carlo methods are very useful if you can easily execute a function lots of time or even in parallel. \n",
"\n",
"We can generate random numbers in many ways, but most programming languages have 'pseudo'-random number generators. \n",
"\n",
"In Python, we use the numpy library as such\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"x=np.random.rand(10)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"#Import rcParams to set font styles\n",
"from matplotlib import rcParams\n",
"\n",
"#Set font style and size \n",
"rcParams['font.family'] = 'sans'\n",
"rcParams['font.size'] = 16\n",
"rcParams['lines.linewidth'] = 3"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(array([3., 1., 0., 0., 1., 0., 0., 2., 1., 2.]),\n",
" array([0.34837708, 0.41148652, 0.47459596, 0.53770539, 0.60081483,\n",
" 0.66392427, 0.72703371, 0.79014314, 0.85325258, 0.91636202,\n",
" 0.97947146]),\n",
" <a list of 10 Patch objects>)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAD9CAYAAABDaefJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALE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+4HP9z9Q7wb+ENi96Pe1nR79ul3vcWDiNddMzHc83V1x76X7zfUO4MIhy/SGXpJUSNVj6pK0Ixl1SSrEqEtSIUZdkgox6pJUiFGXpEKMuiQVYtQlqZD/BbUtv75EOncoAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.hist(x,bins=10, color='b', histtype='bar', edgecolor='w')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `numpy.random.rand(10)` function generates 10 random numbers between 0 and 1. The pyplot function `hist` then displays a histogram of these randomly generated numbers. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise and Discussion\n",
"\n",
"Try generating more random numbers and plotting histograms of the results i.e. increase `10` to larger values. \n",
"\n",
"What should the histogram of `x` look like if Python is generating truly random numbers?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Examples of Monte Carlo models:\n",
"\n",
"Monte Carlo models have a wide array of applications. We are going to use Monte Carlo models in later modules to explore how uncertainty in measurements can be incorporated into computational models. The three main applications for Monte Carlo models are used in three main classes: optimization, numerical integration, and generating population distributions [1]. \n",
"\n",
"Here is a brief list of Monte Carlo model use cases in real-world applications:\n",
"\n",
"- [Eigenvlaues in supercritical systems](https://link.springer.com/chapter/10.1007%2FBFb0049064)\n",
"- [average time between failures for reliability](http://www.egr.msu.edu/~mitraj/research/pubs/proc/singh-mitra_em_stdby_ias95.pdf)\n",
"- disordered materials (physics)\n",
"- [Calculation of the energy output of a wind farm](http://www.mdpi.com/1996-1073/9/4/286/pdf)\n",
"- [US Coast Guard rescue missions](https://en.wikipedia.org/wiki/Search_and_Rescue_Optimal_Planning_System)\n",
"- [Radiation shielding](http://www.sciencedirect.com/science/article/pii/S0920379612000580)\n",
"- [Predict number of asteroids that hit body of water](https://cneos.jpl.nasa.gov/sentry/intro.html)\n",
"- [Financial modeling](https://en.wikipedia.org/wiki/Monte_Carlo_methods_in_finance)\n",
"\n",
"We will explore Monte Carlo modeling through the use of three examples:\n",
"\n",
"1. Calculate the value of $\\pi$\n",
"\n",
"2. Calculate the integral of a function\n",
"\n",
"3. Propagate uncertainty in manufacturing into uncertainty in failure load"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"\n",
"\n",
"# Example 1: Calculate $\\pi$ with random numbers. \n",
"\n",
"Assuming we can actually generate random numbers (a topic of philosophical and heated debates) we can populate a unit square with random points and determine the ratio of points inside and outside of a circle.\n",
"\n",
"![Unit circle and unit square](../images/MonteCarloPi.gif)\n",
"\n",
"![1/4 Unit circle and 1/4 unit square](../images/MonteCarloPi_rand.gif)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"The ratio of the area of the circle to the square is:\n",
"\n",
"$\\frac{\\pi r^{2}}{4r^{2}}=\\frac{\\pi}{4}$\n",
"\n",
"So if we know the fraction of random points that are within the unit circle, then we can calculate $\\pi$\n",
"\n",
"(number of points in circle)/(total number of points)=$\\pi/4$"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.61262684, 0.8262925 , 0.59955407, 0.43229944, 0.66224665,\n",
" 0.61154899, 0.34189469, 0.94126304, 0.41459117, 0.6400169 ])"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.random.rand(10)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"def montecarlopi(N):\n",
" '''Create random x-y-coordinates to and use ratio of circle-to-square to \n",
" calculate the value of pi\n",
" i.e. Acircle/Asquare = pi/4\n",
" Arguments\n",
" ---------\n",
" N: number of random points to produce between x=0-1 and y=0-1\n",
" \n",
" Returns\n",
" -------\n",
" our_pi: the best prediction of pi using N points\n",
" '''\n",
" \n",
"\n",
" x=np.random.rand(N,1);\n",
" y=np.random.rand(N,1);\n",
" R=np.sqrt(x**2+y**2); # compute radius\n",
" num_in_circle=sum(R<1);\n",
" total_num_pts =len(R);\n",
" our_pi = 4*num_in_circle/total_num_pts;\n",
" return our_pi"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"mean value for pi = 3.188800\n",
"standard deviation is 0.041097\n",
"actual pi is 3.141593\n"
]
}
],
"source": [
"test_pi=np.zeros(10)\n",
"for i in range(0,10):\n",
" test_pi[i]=montecarlopi(1000);\n",
"\n",
"print('mean value for pi = %f'%np.mean(test_pi))\n",
"print('standard deviation is %f'%np.std(test_pi))\n",
"print('actual pi is %f'%np.pi)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exercises\n",
"\n",
"1. Why is there a standard deviation for the value of $\\pi$ calculated with a Monte Carlo method? Does it depend upon how many times you run the function i.e. the size of `test_pi`? or the number of random points `N`? Alter the script above to discover correlations\n",
"\n",
"2. How well does our function `montecarlopi` converge to the true value of $\\pi$ (you can use `np.pi` as a true value)? Plot the convergence as we did in [03-Numerical_error](https://github.uconn.edu/rcc02007/CompMech01-Getting-started/blob/master/notebooks/03-Numerical_error.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example 2: Calculate the integral of a function\n",
"\n",
"One way to calculate the integral of a function, $f(x)$, is to approximate it as a Riemann sum as such\n",
"\n",
"$I=\\int_{a}^{b}f(x) dx \\approx \\Delta x \\left(f(a)+f(a+\\Delta x)+f(a+2\\Delta x)+...+f(b)\\right))$.\n",
"\n",
"Another way to integrate this function is with a [Monte Carlo approach](https://en.wikipedia.org/wiki/Monte_Carlo_integration) [2, 3]. We can approximate the integral as such\n",
"\n",
"$I=\\int_{a}^{b}f(x) dx \\approx \\frac{1}{n}\\sum_{i=1}^n f(x_i)$. \n",
"\n",
"where $x_i$ are uniformly random values of $x$ over the interval $[a,b]$. We were actually doing this in two dimensions in Example #1 when we compared the area of the circle to the area of a square. \n",
"\n",
"Visually, this approximation can be represented by the following figure.\n",
"\n",
"![Integration approximation](../images/integrals.png)\n",
"\n",
"The figure above shows the exact integral on the left as compared to two approximations, the Riemann sum (top-right) and Monte Carlo method (bottom-right). \n",
"\n",
"The main benefit in using a Monte Carlo integration over a Riemann sum (or another non-random method e.g. trapezoidal) is that the integration converges as \n",
"\n",
"$error \\approx \\frac{1}{\\sqrt{n}}$\n",
"\n",
"independent of the number of dimensions in the formula. Non-random methods have convergence rates that depend upon the step size along each axis, so with two dimensions reducing the step size to 1/3 increases n by 4, in three dimensions its 8, in 4D its 16, and so on. We'll do an example with a 1D function to introduce the concept. \n",
"\n",
"You can even integrate functions that are not easy to evaluate, such as the [area of light shown by the bat signal](http://leios.github.io/Batman_Montecarlo)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise (Discussion)\n",
"\n",
"Why does the Monte Carlo method work? Is there a benefit to random numbers as opposed to using an ordered set divided into equally-spaced intervals?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this example, we will calculate the integral $I=\\int_{1}^{3}f(x)dx$ where\n",
"\n",
"$I=\\int_{1}^{3}\\frac{x}{1+x^2}dx \\approx \\frac{1}{n}\\sum_{i=1}^n \\frac{x_i}{1+x_i^2}$\n",
"\n",
"Our first objective is to take random numbers between 0 and 1 and turn them into random number between 1 and 3. This process is called _scaling_ or _transforming_ our variable $x_{i}$"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEU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+RZowx4ERGpXmMcgxcRETco4EVEHEoBLyLiUAp4ERGHUsCLiDiUAl5ExKEU8CIiDqWAFxFxqP8PyZ8DpT/ZHVoAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"ri=np.random.rand(100)\n",
"\n",
"xi=1+(3-1)*ri # scaling equation for our uniform distribution 0..1 to 1..3\n",
"\n",
"plt.hist(xi,label='x_i: our scaled var')\n",
"plt.hist(ri,label='r_i: our original var')\n",
"plt.legend();\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"\n",
"Compare the scaled histogram to the original histogram. What is similar? What is different?\n",
"\n",
"Make a scaling equation to get uniformly random numbers between 10 and 20. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Performing the integration\n",
"\n",
"If you have been doing a lot of calculus lately, you may know that \n",
"\n",
"$\\int\\frac{x}{1+x^2}dx = \\frac{\\log({x^2+1})}{2}$. \n",
"\n",
"If not, Python's [Sympy: Symbolic algebra](https://docs.sympy.org/1.5.1/modules/integrals/integrals.html) can help you jog your memory [4]. It will also give us an exact solution to judge our convergence. \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{\\log{\\left(x^{2} + 1 \\right)}}{2}$"
],
"text/plain": [
"log(x**2 + 1)/2"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sympy\n",
"\n",
"x=sympy.Symbol('x')\n",
"\n",
"sympy.integrate(x/(1+x**2),x)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.80471895621705$"
],
"text/plain": [
"0.804718956217050"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sympy.integrate(x/(1+x**2),(x,1,3)).evalf()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So the exact integral that we are approximating is\n",
"\n",
"$I=\\frac{\\log{10}}{2}-\\frac{\\log{2}}{2}=0.80471895621705$\n",
"\n",
"_Note: We won't be using sympy for general numerical methods. It is helpful to do some algebra for us, but in general we want to use arrays so that our solutions can be scaled up and solved quicker by the computer._"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.7824846191561594\n"
]
},
{
"data": {
"text/plain": [
"Text(0, 0.5, 'f(x)')"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAdcAAAE7CAYAAACPAss4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOzdd3wUdfrA8c+TIFXqEYqI9CJFiqFJFcSGFOUU0FOKBRTrqVhQj1PPguXn2RBOFPRU9BRFUKwQpaMiIE1EQIrSi3QIPL8/vpNls2ySDdnNbJLn/XrltdnvtGdnZ+eZ73dmviOqijHGGGOiJ8HvAIwxxpj8xpKrMcYYE2WWXI0xxpgos+RqjDHGRJklV2OMMSbKLLkaY4wxUZavk6uIjBARFZFOEY4/wBt/QGwjCyxvrYisjXDcEz6LiHTyykaEjKsikhLNWPOC7KzPeCPOXSKyQkQOet9hL7/jMlnL6HcY7/POj+JpfWUruYpICxEZKyI/i8heETkkIhtEZLKIXCcixWMVqIlPIjLO25ir58KycvXgJ5ddBTwF7AWeBf4JrMhsAm9dqIjsEZFTMxinUdB4C6MedebxpYhIrt1ILyIXi8j/RGS9d4CyR0QWisjTIlInt+KIR3n5wDNU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zbrN/YHjqmrDgPEmRpICVlfVTUNnmVQW147aaxZrgRU0NzK9BFxRVRuHzDVm7YE7l+mqOnkhs4xdko3AfDsL3VJVNy9cmvFLci3NDmCHAEuAL4BXgDUekzvO4tqdxVWSpJ55zVWSpJ5ZXCVJ6pnFVZKknllcJUnqmcVVkqSeWVwlSeqZxVWSpJ5ZXCVJ6pnFVZKknllcpZFKskeSj5KsbzvjzLy/MskfSS4dMp+k+bn9oTRiSY4G1gFrq+q6JPvSbEq/vqrOHDadpPlYXKWRS3IlcBewkqbH5hHAUVX19aDBJM3L4iqNXJIAzwLLaTq9rKiql4ZNJWlbvOYqjVw1Z8APAVPAuxZWafwsrtLIJdkfuIemCfhRSS4fOJKk7bC4SiPWTgk/CGwBVtAU2duTHDloMEnb5DVXacSSXAXcASyvqukkS2juHp4Cjq2qXwYNKGlOjlylkWqX4dwGrKmqaYCq2gKcAxwM3D1cOknb4shVkqSeOXKVJKlnFldJknpmcZUkqWcWV0mSemZxlSSpZxZXSZJ6ZnGVJKlnFldJknr2JyX0Vfrsz2CuAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"f= lambda x:x/(1+x**2)\n",
"\n",
"n=10\n",
"ri=np.random.rand(n)\n",
"\n",
"xi=1+(3-1)*ri # scaling equation for our uniform distribution 0..1 to 1..3\n",
"# we scaled our variable by a factor of 2 so we scale the bins accorcdingly\n",
"bin_scale = 3-1 \n",
"\n",
"my_I=sum(f(xi))/n*bin_scale\n",
"print(my_I)\n",
"\n",
"plt.bar(xi,f(xi),width=bin_scale/n,color=[0.1,0,1,0.5])\n",
"plt.plot(np.linspace(0,4),f(np.linspace(0,4)),color='k')\n",
"plt.title('Graphical illustration of Monte Carlo'+\\\n",
" ' integration\\n I={:.4f}'.format(my_I))\n",
"plt.xlabel('x')\n",
"plt.ylabel('f(x)')\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"def montecarlo_integrate(f,a,b,N):\n",
" '''Estimate the integral of a function f(x) from a->b with N \n",
" randomly chosen points\n",
" Arguments\n",
" ---------\n",
" f: a function of the form f=lambda x: ...\n",
" a: the lower bound of the integration\n",
" b: the upper bound of the integration\n",
" N: number of random points to produce between xi=a-b\n",
" \n",
" Returns\n",
" -------\n",
" our_I: the best prediction of the integral using N points \n",
" '''\n",
" ri=np.random.rand(n)\n",
"\n",
" xi=a+(b-a)*ri # scaling equation for our uniform distribution 0..1 to 1..3\n",
" # we scaled our variable by a factor of 2 so we scale the bins accorcdingly\n",
" bin_scale = b-a\n",
"\n",
" our_I=sum(f(xi))/n*bin_scale\n",
" \n",
" return our_I\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the above function, we have defined a general Monte Carlo integration function. Now, we can create a for loop to try the function multiple times and get an average and standard deviation. "
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"mean value is I = 0.81410075695566\n",
"standard deviation is 0.028138512733038436\n",
"actual I = 0.80471895621705\n",
"error in mean = -0.009381800738609947\n"
]
}
],
"source": [
"test_I=np.zeros(10)\n",
"for i in range(0,10):\n",
" test_I[i]=montecarlo_integrate(f,1,3,500);\n",
"\n",
"print('mean value is I = {}'.format(np.mean(test_I)))\n",
"print('standard deviation is {}'.format(np.std(test_I)))\n",
"print('actual I = 0.80471895621705')\n",
"print('error in mean = {}'.format(0.80471895621705-np.mean(test_I)))"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### Example 3: Determine uncertainty in failure load based on geometry uncertainty\n",
"\n",
"In this example, we know that a steel bar will break under 940 MPa tensile stress. The bar is 1 mm by 2 mm with a tolerance of 10 %. What is the range of tensile loads that can be safely applied to the beam?\n",
"\n",
"$\\sigma_{UTS}=\\frac{F_{fail}}{wh}$\n",
"\n",
"$F_{fail}=\\sigma_{UTS}wh$"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZUAAAElCAYAAAAskX9OAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deZgcVb3G8e8LSVgFEllkD/uu6I0simwiOwFlEUVBFvEiCrJdZRFDAFFRZBeQ3aCggBBQISAEBMMSNChhEwibLCYEgUAgBH73j3OadDrdPTUz1TPTmffzPP3UdNWpqtM1M/Xrs9Q5igjMzMzKME9vZ8DMzOYeDipmZlYaBxUzMyuNg4qZmZXGQcXMzErjoGJmZqVxUGlDkk6SFJI2qVq3VV53XG/mrQhJA3Jeb+3tvED969kk7ao57YU9kTebu/W1/4UyOKi0iKSh+Y+l0eu/vZ1H6ztysDpB0o2SXsx/I+O7eKwhkk6R9JCkaZJelnS3pL0lzVsn/YKSTpT0mKR3JE2RdK2kdbv/yZrmc938Ob/VzePMK+kISQ9LelvSS5IulrR0J46xhqTjJN2V939H0tOSzpe0fJ30y0s6XNKfJT0vaYakf0saJWnt7nyeDvJ5V75mr0tavM72SpDq0t9OGQb01on7kceAK+usf7sbxzwdGAU8041jWNc8A6wFlP2lYHPgeGAm8Ajwka4cRNKHgQeAFYHbgD8CCwM7A5cBmwH7V6VfEBgLfBL4G3AOsCSwG7CNpC0j4t6u5KWA4Xk5upvHuRT4CvAgcAawArA3sJWkDSLipQLHOBnYFZgAXA28BWwIHAjsJunTEfFoVfpDgSNI/99/BKYC6wF7AbtK2joi/tLNz9XMh4BjgcNaeI6uiQi/WvAChgIBXNdD59sqn++43v7sBfI6IOf11t7OS87PSTk/m/R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4qJWnstaxyUVM2vmV8C/yaMHtNg3gP+QHuS0NuWgYmYN5WdP9iN14W61d4CvVT+jY+3H1V9mZlYal1TMzKw0DipmZlYaBxUzMyuNg4qZmZXGQcXMzErz/z00/+E2CiW6AAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"N=10000;\n",
"r=np.random.rand(N,1);\n",
"wmean=1; # in mm\n",
"wmin=wmean-wmean*0.1;\n",
"wmax=wmean+wmean*0.1;\n",
"hmean=2; # in mm\n",
"hmin=hmean-hmean*0.1;\n",
"hmax=hmean+hmean*0.1;\n",
"\n",
"wrand=wmin+(wmax-wmin)*r;\n",
"hrand=hmin+(hmax-hmin)*r;\n",
"\n",
"uts=940; # in N/mm^2=MPa\n",
"\n",
"Ffail=uts*wrand*hrand*1e-3; # force in kN\n",
"plt.hist(Ffail,bins=20,)\n",
"plt.xlabel('failure load (kN)')\n",
"plt.ylabel('relative counts')\n",
"plt.title('Failure load is {:.2f}+/- {:.2f} kN'.format(np.mean(Ffail),np.std(Ffail)));"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Normally, the tolerance is not a maximum/minimum specification, but instead a normal distribution that describes the standard deviation, or the 68% confidence interval.\n",
"\n",
"So instead, we should generate normally distributed dimensions."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAESCAYAAADuVeJ5AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAf60lEQVR4nO3debgcVbnv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R18knYswGdii1++py/vrC6QzvZ8C5pNO6jyLyom0wLi8vw6oWXcE8CNSf8Z8UlJ5Wyvl8MUHzcysiPswzMysiBOGmZkVccIwM7MiThhmZlbECcPMzIo4YZiZWREnDDMzK+KEYWZmRf4/nJ+iY8c11WgAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"N=10000;\n",
"wmean=1; # in mm\n",
"wstd=wmean*0.1; # standard deviation in mm\n",
"hmean=2; # in mm\n",
"hstd=hmean*0.1; # standard deviation in mm\n",
"\n",
"\n",
"wrand=np.random.normal(wmean,wstd,size=N);\n",
"hrand=np.random.normal(hmean,hstd,size=N);\n",
"uts=940; # in N/mm^2=MPa\n",
"\n",
"Ffail=uts*wrand*hrand*1e-3; # force in kN\n",
"plt.hist(Ffail,bins=20)\n",
"#plt.xlabel('failure load (kN)')\n",
"#plt.ylabel('relative counts')\n",
"plt.title('Failure load is {:.2f}+/- {:.2f} kN'.format(np.mean(Ffail),np.std(Ffail)));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this propagation of uncertainty, the final value of failure load seems to be independent of wheher the distribution is uniformly random or normally distributed. In both cases, the failure load is $\\approx 1.9 \\pm 0.25$ kN.\n",
"\n",
"The difference is much more apparent if you look at the number of occurrences that failure will occur whether the dimensions are uniformly random or normally distributed. \n",
"\n",
"For the uniformly random case, there are approximately 500 parts out of 10,000 that will fail at 1.9 kN. \n",
"\n",
"For the normally distributed case, there are approximately 1500 parts out of 10,000 that will fail at 1.9 kN. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Where does a normal distribution come from?\n",
"\n",
"\"Everybody believes in the exponential law of errors: the experimenters, because they think it can be proved by mathematics; and the mathematicians, because they believe it has been established by observation\" [5].\n",
"\n",
"In the previous example, we drew dimensions from uniformly random distributions and normally distributed random distributions. Why do we use the \"normal\" distribution to describe data with a mean and standard deviation? There are exact statistical methods to derive the normal distribution, but let's take a look at a Monte Carlo approach. \n",
"\n",
"Let's say there are 10 different independent factors that could change the dimensions of the steel bar in question e.g. which tool was used, how old the blade is, the humidity, the temperature, and the list goes on. \n",
"\n",
"Let's consider one dimension. \n",
"Each of these factors could change the dimensions of the part, let's use a uniform scale of -1/2-1/2.\n",
"If the effect is 0, the dimension is exactly as specified. If the effect is -1/2, the dimension is much smaller. Conversely, if the effect is 1/2 the dimension is much larger. Now, we use a Monte Carlo model to generate 10 effects on 10,000 parts as shown in the next block."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"factors = np.random.rand(10000,10)-1/2 # each row represents a part and each column is an effect (-1/2-1/2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, we have created 10,000 parts with 10 uniformly random effects between -1/2-1/2. \n",
"\n",
"We sum the effects and look at the final part distribution. The x-axis is labeled \"A.U.\" for arbitrary units, we are just assuming an effect of -1/2-1/2 for each of the 10 factors. "
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Text(0, 0.5, 'number of parts')"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZUAAAEQCAYAAAB4JulQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAdSUlEQVR4nO3debRcVZn+8e/DlDA2CWDTRGKCaC8ZDNqRBkVGf0ATCCIiMjRDWmgRVERmFCIkTEEZmkZlAQk/oIVGpA0NmpAmhNYOCoQgBEGBJJAmjEEgEAMhb/+xd0mlUvfm3JtTValbz2etWqfq7F2n3rrr5r7ZZ0+KCMzMzMqwWqsDMDOzvsNJxczMSuOkYmZmpXFSMTOz0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x8RY4Gjge2Am0kd/iOBs4Cv1FxztXwNdfGZ1sG8nbCZmZXGLRUzMyuNk4qZmZXGScXMzErjpGJmZqVxUjEzs9I4qZiZWWmcVMzMrDROKmZmVpr/A/wt4URURV3eAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"dims = np.sum(factors,axis=1)\n",
"\n",
"plt.hist(dims,30)\n",
"plt.xlabel('effect A.U.')\n",
"plt.ylabel('number of parts')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, depending upon which random numbers were generated, you should see what looks like a normal distribution. \n",
"\n",
"Normal distributions come from the assumption that we have a large (or infinite) number of uncontrollable factors that can change our desired result. In our case, ideally each factor would have an effect of 0, because then it is exactly as specified, but the reality is that we can't control most factors. As engineers, we always have to consider the uncertainty in our models and measurements. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## We learned:\n",
"\n",
"* How to generate \"random\" numbers in Python$^+$\n",
"* The definition of a Monte Carlo model\n",
"* How to calculate $\\pi$ with Monte Carlo\n",
"* How to take the integral of a function with Monte Carlo\n",
"* How to propagate uncertainty in a model with Monte Carlo\n",
"* **Bonus**: use Sympy to do calculus and algebra for us! *no need for Wolfram, sorry Stephen*\n",
"* How to generate a normal distribution using uniformly random numbers\n",
"\n",
"$^+$ Remember, the computer only generates pseudo-random numbers. For further information **and** truly random numbers check [www.random.org](https://www.random.org/randomness/) "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# References\n",
"\n",
"1. [Why the Monte Carlo method is so important today\n",
"Dirk P. Kroese, Tim Brereton *et al.* Wiley Interdisciplinary Reviews: Computational Statistics, 6, 6, 11 2014](https://onlinelibrary.wiley.com/doi/full/10.1002/wics.1314)\n",
"\n",
"2. [Wikipedia: Monte Carlo integration](https://en.wikipedia.org/wiki/Monte_Carlo_integration)\n",
"\n",
"3. [Weinzierl, S. (2000). \"Introduction to Monte Carlo methods\"](https://arxiv.org/abs/hep-ph/0006269)\n",
"\n",
"4. Meurer A, _et al._ (2017) SymPy: symbolic computing in Python. PeerJ Computer Science 3:e103 https://doi.org/10.7717/peerj-cs.103\n",
"\n",
"5. Whittaker, E. T. and Robinson, G. \"Normal Frequency Distribution.\" Ch. 8 in The Calculus of Observations: A Treatise on Numerical Mathematics, 4th ed. New York: Dover, p. 179, 1967."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Problems\n",
"\n",
"1. Calculate the area of a unit circle using the Monte Carlo integration method that we devloped in Example 2. Calculate the area of a quarter of the circle, then multiply the final result by 4. \n",
"\n",
" _Hint: You have to create a function that describes the perimeter of the circle._\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"2. 100 steel rods are going to be used to support a 1000 kg structure. The\n",
"rods will buckle when the load in any rod exceeds the [critical buckling\n",
"load](https://en.wikipedia.org/wiki/Euler%27s_critical_load)\n",
"\n",
" $P_{cr}=\\frac{\\pi^3 Er^4}{16L^2}$\n",
"\n",
" where E=200e9 Pa, r=0.01 m +/-0.001 m, and L is the \n",
" length of the rods supporting the structure. Create a Monte\n",
" Carlo model `montecarlo_buckle` that predicts \n",
" the mean and standard deviation of the buckling load for 100\n",
" samples with normally distributed dimensions r and L. \n",
"\n",
" ```python\n",
" mean_buckle_load,std_buckle_load=\\\n",
" montecarlo_buckle(E,r_mean,r_std,L,N=100)\n",
" ```\n",
"\n",
" a. What is the mean_buckle_load and std_buckle_load for L=5 m?\n",
"\n",
" b. What length, L, should the beams be so that only 2.5% will \n",
" reach the critical buckling load?"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"def montecarlo_buckle(E,r_mean,r_std,L,N=100):\n",
" '''Generate N rods of length L with radii of r=r_mean+/-r_std\n",
" then calculate the mean and std of the buckling loads in for the\n",
" rod population holding a 1000-kg structure\n",
" Arguments\n",
" ---------\n",
" E: Young's modulus [note: keep units consistent]\n",
" r_mean: mean radius of the N rods holding the structure\n",
" r_std: standard deviation of the N rods holding the structure\n",
" L: length of the rods (or the height of the structure)\n",
" N: number of rods holding the structure, default is N=100 rods\n",
" Returns\n",
" -------\n",
" mean_buckle_load: mean buckling load of N rods under 1000*9.81/N-Newton load\n",
" std_buckle_load: std dev buckling load of N rods under 1000*9.81/N-Newton load\n",
" '''\n",
" \n",
" # your code here"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"3. Generate your own normal distribution using uniformly random numbers between -1/2 and 1/2. \n",
"\n",
" a. What is the effect of changing the number of factors?\n",
" \n",
" b. What is the effect of changing the number of samples?\n",
" \n",
" *Hint: for a-b try plotting histograms of the results.*\n",
" \n",
" c. How would you change the mean in your generated distribution?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"celltoolbar": "Slideshow",
"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.7.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}