Skip to content

Instantly share code, notes, and snippets.

@jon1scr
Created February 18, 2021 15:32
Show Gist options
  • Save jon1scr/e79d4ae88a0ecb6a99e24b9e1784e4f8 to your computer and use it in GitHub Desktop.
Save jon1scr/e79d4ae88a0ecb6a99e24b9e1784e4f8 to your computer and use it in GitHub Desktop.
RiskEngineering notebooks
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Coins and dice"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://risk-engineering.org/static/img/logo-RE.png\" width=\"100\" alt=\"\" style=\"float:right;margin:15px;\">\n",
"\n",
"\n",
"This notebook is an element of the free [risk-engineering.org courseware](https://risk-engineering.org/). It can be distributed under the terms of the [Creative Commons Attribution-ShareAlike licence](https://creativecommons.org/licenses/by-sa/4.0/). \n",
"\n",
"Author: Eric Marsden <eric.marsden@risk-engineering.org>. \n",
"\n",
"---\n",
"\n",
"In this notebook, we illustrate NumPy features for working with discrete probability distributions, such as those resulting from a coin toss or a dice roll. We also show how to use the [SymPy symbolic mathematics library](https://sympy.org/) to analyze probability problems analytically.\n",
"See the [associated course materials](https://risk-engineering.org/statistical-modelling/) for background information and to download this content as a Jupyter notebook."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We start by importing a number of Python libraries and setting up some configuration settings. "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import numpy\n",
"import scipy.stats\n",
"import matplotlib.pyplot as plt\n",
"plt.style.use(\"bmh\")\n",
"%config InlineBackend.figure_formats=[\"svg\"]\n",
"numpy.set_printoptions(threshold=20)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When undertaking statistical analyses, it can be important for your results to be *reproducible*, meaning that you obtain the same results each time you run the analysis. The pseudorandom number generator used by NumPy generates long sequences of outputs that are fully determined by the *seed* of the generator (if you use the same seed, you will obtain the same results each time you run the notebook). In default setting, the seed is taken from some unpredictable feature of the computer environment (such as the `/dev/random` device on a Linux/Unix computer), so sucessive runs will generate different results. If you want a reproducible notebook, you can set the random seed explicitly. "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"numpy.random.seed(42)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let’s **simulate a coin toss** by a random choice between the numbers 0 and 1 (say 0 represents tails and 1 represents heads). Note that the second argument to `randint` is an *exclusive* upper bound."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"numpy.random.randint(0, 2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let’s toss two coins, which gives as an array with the result of the first and second toss."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 0])"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"numpy.random.randint(0, 2, 2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The number of heads when tossing a coin twice is simply the sum of that array."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"numpy.random.randint(0, 2, 2).sum()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Task**: simulate the *number of heads when tossing a coin twice*. Do this 1000 times, calculate the expected value of the number of heads, and plot the distribution of results (the Probability Mass Function)."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 0, 1, ..., 0, 2, 2])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"N = 1000\n",
"heads = numpy.zeros(N, dtype=int)\n",
"for i in range(N):\n",
" heads[i] = numpy.random.randint(0, 2, 2).sum()\n",
"heads"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The **expected value** (or mathematical expectation) of the number of heads is simply the mean of our observations (it’s what happens “on average”). "
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.987"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"heads.mean()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now let’s look at the **distribution** of the number of heads obtained. Let’s count how many times we have scored 0, 1 or 2 in our 1000 simulations, using the `unique` function from `numpy`, then plot that probability mass function. "
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
"<svg height=\"250.2675pt\" version=\"1.1\" viewBox=\"0 0 375.02 250.2675\" width=\"375.02pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
" <metadata>\n",
" <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
" <cc:Work>\n",
" <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
" <dc:date>2020-10-02T13:10:20.567867</dc:date>\n",
" <dc:format>image/svg+xml</dc:format>\n",
" <dc:creator>\n",
" <cc:Agent>\n",
" <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n",
" </cc:Agent>\n",
" </dc:creator>\n",
" </cc:Work>\n",
" </rdf:RDF>\n",
" </metadata>\n",
" <defs>\n",
" <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
" </defs>\n",
" <g id=\"figure_1\">\n",
" <g id=\"patch_1\">\n",
" <path d=\"M 0 250.2675 \n",
"L 375.02 250.2675 \n",
"L 375.02 0 \n",
"L 0 0 \n",
"z\n",
"\" style=\"fill:none;\"/>\n",
" </g>\n",
" <g id=\"axes_1\">\n",
" <g id=\"patch_2\">\n",
" <path d=\"M 33.02 224.64 \n",
"L 367.82 224.64 \n",
"L 367.82 7.2 \n",
"L 33.02 7.2 \n",
"z\n",
"\" style=\"fill:#eeeeee;\"/>\n",
" </g>\n",
" <g id=\"matplotlib.axis_1\">\n",
" <g id=\"xtick_1\">\n",
" <g id=\"line2d_1\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 48.238182 224.64 \n",
"L 48.238182 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_2\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 0 -3.5 \n",
"\" id=\"mbce9441bc7\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"48.238182\" xlink:href=\"#mbce9441bc7\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_1\">\n",
" <!-- 0.0 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(39.038182 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 22.796875 -1 \n",
"C 30.5 -1 42.09375 7.5 42.09375 30.90625 \n",
"C 42.09375 46.5 36.40625 54.203125 32.796875 57.5 \n",
"C 30.09375 60 26.90625 61 23.296875 61 \n",
"C 13.296875 61 3.90625 48.59375 3.90625 28.90625 \n",
"C 3.90625 12.703125 10.40625 -1 22.796875 -1 \n",
"z\n",
"M 23.296875 57.09375 \n",
"C 25 57.09375 26.59375 56.5 27.703125 55.5 \n",
"C 30.796875 52.90625 33.5 45.09375 33.5 31.703125 \n",
"C 33.5 22.5 33.203125 17.296875 31.796875 12.203125 \n",
"C 29.59375 3.90625 24.703125 2.90625 22.90625 2.90625 \n",
"C 13.59375 2.90625 12.5 20 12.5 28.703125 \n",
"C 12.5 53.40625 18.703125 57.09375 23.296875 57.09375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-48\"/>\n",
" <path d=\"M 5.40625 4.59375 \n",
"C 5.40625 1.40625 7.90625 -1.09375 11 -1.09375 \n",
"C 14.09375 -1.09375 16.59375 1.40625 16.59375 4.59375 \n",
"C 16.59375 7.703125 14.09375 10.203125 11 10.203125 \n",
"C 7.90625 10.203125 5.40625 7.703125 5.40625 4.59375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-46\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_2\">\n",
" <g id=\"line2d_3\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 124.329091 224.64 \n",
"L 124.329091 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_4\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"124.329091\" xlink:href=\"#mbce9441bc7\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_2\">\n",
" <!-- 0.5 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(115.129091 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 20.203125 -1 \n",
"C 32.09375 -1 40.59375 7.796875 40.59375 19.59375 \n",
"C 40.59375 29.296875 34.09375 38 22.90625 38 \n",
"C 18.796875 38 14.203125 37.296875 12 36.5 \n",
"L 14.09375 54.203125 \n",
"C 17.796875 53.703125 22.09375 53.296875 26.796875 53.296875 \n",
"C 29.796875 53.296875 33.203125 53.40625 37.296875 53.90625 \n",
"L 38.90625 60.703125 \n",
"L 38.203125 61 \n",
"C 32.5 60.296875 27.09375 60 21.796875 60 \n",
"C 18.09375 60 13.796875 60.296875 10.40625 60.59375 \n",
"L 7.203125 31.203125 \n",
"L 7.90625 30.90625 \n",
"C 11.90625 32.5 15.59375 34 20.296875 34 \n",
"C 26.796875 34 31.796875 28.796875 31.796875 17.90625 \n",
"C 31.796875 8.703125 27.203125 3 20.40625 3 \n",
"C 12.90625 3 11.59375 7 8.296875 13 \n",
"L 6.90625 12.90625 \n",
"L 4.703125 4.90625 \n",
"L 5.09375 4.59375 \n",
"C 7.59375 2.40625 12.59375 -1 20.203125 -1 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-53\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_3\">\n",
" <g id=\"line2d_5\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 200.42 224.64 \n",
"L 200.42 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_6\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"200.42\" xlink:href=\"#mbce9441bc7\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_3\">\n",
" <!-- 1.0 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(191.22 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 28.59375 18.90625 \n",
"L 28.59375 44.296875 \n",
"C 28.59375 55.09375 29.203125 59.09375 29.40625 60.5 \n",
"C 29.40625 61 29.09375 61 28.703125 61 \n",
"C 22.203125 58.90625 14.59375 55 6.796875 52.59375 \n",
"L 7.40625 49.703125 \n",
"C 11.90625 50.203125 16.796875 51.296875 18.796875 51.296875 \n",
"C 20.59375 51.296875 20.59375 47.296875 20.59375 43.703125 \n",
"L 20.59375 18.90625 \n",
"C 20.59375 11.09375 20.5 5.703125 19.796875 0 \n",
"L 19.90625 -0.296875 \n",
"C 19.90625 -0.296875 22.703125 0 24.5 0 \n",
"C 26.5 0 29.296875 -0.296875 29.296875 -0.296875 \n",
"L 29.5 0 \n",
"C 28.796875 6 28.59375 11 28.59375 18.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-49\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_4\">\n",
" <g id=\"line2d_7\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 276.510909 224.64 \n",
"L 276.510909 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_8\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"276.510909\" xlink:href=\"#mbce9441bc7\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_4\">\n",
" <!-- 1.5 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(267.310909 239.3075)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_5\">\n",
" <g id=\"line2d_9\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 352.601818 224.64 \n",
"L 352.601818 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_10\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"352.601818\" xlink:href=\"#mbce9441bc7\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_5\">\n",
" <!-- 2.0 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(343.401818 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 22.203125 55.296875 \n",
"C 27.40625 55.296875 32.796875 50.5 32.796875 43.5 \n",
"C 32.796875 39.296875 31.59375 34 29 30.09375 \n",
"C 21.796875 19.40625 10.40625 9.40625 5.40625 4.703125 \n",
"C 5.296875 4.296875 5.296875 3.90625 5.296875 3.40625 \n",
"C 5.296875 1.90625 5.796875 0.40625 6.296875 -0.5 \n",
"C 13.703125 -0.296875 17.90625 0 25.203125 0 \n",
"C 32.40625 0 35.40625 -0.203125 42.59375 -0.5 \n",
"C 42.40625 0.5 42.296875 1.703125 42.296875 2.796875 \n",
"C 42.296875 4.40625 42.40625 6 42.796875 7.5 \n",
"C 37.09375 7 34.09375 6.703125 24.5 6.703125 \n",
"C 21 6.703125 19 6.703125 16.296875 6.5 \n",
"C 16.203125 6.703125 16.203125 6.796875 16.203125 7 \n",
"C 16.203125 7.90625 17.203125 9 17.90625 9.703125 \n",
"C 22.796875 14.40625 27.5 18.90625 34.09375 27.796875 \n",
"C 37.796875 32.796875 41.40625 39.203125 41.40625 44.90625 \n",
"C 41.40625 54.40625 35 61 23.796875 61 \n",
"C 14.703125 61 8.90625 55.90625 6.59375 52.90625 \n",
"L 8.796875 46 \n",
"L 10.09375 45.90625 \n",
"C 11.5 48.90625 12 51 14.5 53 \n",
"C 16.5 54.59375 19.40625 55.296875 22.203125 55.296875 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-50\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"matplotlib.axis_2\">\n",
" <g id=\"ytick_1\">\n",
" <g id=\"line2d_11\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 33.02 214.756364 \n",
"L 367.82 214.756364 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_12\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 3.5 0 \n",
"\" id=\"m793d0210d9\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"33.02\" xlink:href=\"#m793d0210d9\" y=\"214.756364\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_6\">\n",
" <!-- 0 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(22.08 220.340114)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_2\">\n",
" <g id=\"line2d_13\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 33.02 172.965089 \n",
"L 367.82 172.965089 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_14\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"33.02\" xlink:href=\"#m793d0210d9\" y=\"172.965089\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_7\">\n",
" <!-- 100 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 178.548839)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_3\">\n",
" <g id=\"line2d_15\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 33.02 131.173815 \n",
"L 367.82 131.173815 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_16\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"33.02\" xlink:href=\"#m793d0210d9\" y=\"131.173815\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_8\">\n",
" <!-- 200 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 136.757565)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_4\">\n",
" <g id=\"line2d_17\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 33.02 89.382541 \n",
"L 367.82 89.382541 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_18\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"33.02\" xlink:href=\"#m793d0210d9\" y=\"89.382541\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_9\">\n",
" <!-- 300 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 94.966291)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 20.90625 2.90625 \n",
"C 13 2.90625 11.90625 5.90625 9.203125 11.703125 \n",
"L 7.703125 11.59375 \n",
"L 5.5 4.09375 \n",
"L 5.796875 3.796875 \n",
"C 8.40625 1.59375 12.703125 -1 20.703125 -1 \n",
"C 29.203125 -1 42.59375 4.796875 42.59375 18 \n",
"C 42.59375 25.90625 36.5 31.5 28.796875 32.203125 \n",
"L 28.796875 32.703125 \n",
"C 34 33.90625 40.59375 39.703125 40.59375 48 \n",
"C 40.59375 55.203125 34.40625 61 24.5 61 \n",
"C 16.796875 61 11.203125 57.59375 8.703125 55.40625 \n",
"L 8.40625 55.09375 \n",
"L 10.5 48.703125 \n",
"L 12 48.59375 \n",
"C 14.40625 54.203125 17.59375 57.09375 23.59375 57.09375 \n",
"C 27.5 57.09375 31.90625 53 31.90625 46.5 \n",
"C 31.90625 42.09375 30.40625 38.90625 28.09375 36.703125 \n",
"C 26.09375 34.796875 23.203125 33.90625 19.796875 33.90625 \n",
"C 18.59375 33.90625 17.5 34 16.09375 34.203125 \n",
"L 16.09375 29.796875 \n",
"C 17.296875 30 19.40625 30 20.296875 30 \n",
"C 23.5 30 27.296875 29.09375 30.09375 26.796875 \n",
"C 32.703125 24.59375 34 21.09375 34 17.203125 \n",
"C 34 5.09375 24.5 2.90625 20.90625 2.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-51\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-51\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_5\">\n",
" <g id=\"line2d_19\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 33.02 47.591267 \n",
"L 367.82 47.591267 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_20\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"33.02\" xlink:href=\"#m793d0210d9\" y=\"47.591267\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_10\">\n",
" <!-- 400 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 53.175017)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 28.59375 14.796875 \n",
"C 28.59375 7.09375 28.40625 5.09375 27.796875 0 \n",
"L 27.90625 -0.296875 \n",
"C 27.90625 -0.296875 31 0 32.59375 0 \n",
"C 34.203125 0 35.90625 -0.296875 36.796875 -0.296875 \n",
"C 36.90625 -0.296875 37 -0.09375 37 0 \n",
"C 36.59375 5.796875 36.40625 9 36.40625 14.796875 \n",
"L 41.40625 14.796875 \n",
"C 42.796875 14.796875 44.296875 17.09375 44.296875 18.203125 \n",
"C 44.296875 19.09375 43.796875 19.796875 42.796875 19.796875 \n",
"L 36.40625 19.796875 \n",
"L 36.40625 45.203125 \n",
"C 36.40625 48.5 36.5 55.40625 37 60 \n",
"C 37 60.203125 36.90625 60.40625 36.796875 60.40625 \n",
"C 35.90625 60.40625 34.40625 60 32.90625 60 \n",
"C 31.296875 60 29.5 60.40625 29.5 60.40625 \n",
"C 29.5 60.40625 29.09375 60.09375 29.09375 60 \n",
"C 23 51.59375 8.59375 29.59375 3.40625 20.703125 \n",
"C 2.40625 18.90625 2.09375 17.796875 2.09375 16.796875 \n",
"C 2.09375 15.296875 4.40625 14.796875 8 14.796875 \n",
"z\n",
"M 28.59375 51.203125 \n",
"L 28.59375 19.796875 \n",
"L 8.296875 19.796875 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-52\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-52\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"LineCollection_1\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 48.238182 214.756364 \n",
"L 48.238182 101.919923 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 200.42 214.756364 \n",
"L 200.42 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 352.601818 214.756364 \n",
"L 352.601818 107.352789 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"line2d_21\">\n",
" <defs>\n",
" <path d=\"M 0 3 \n",
"C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
"C 2.683901 1.55874 3 0.795609 3 0 \n",
"C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
"C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
"C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
"C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
"C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
"C -1.55874 2.683901 -0.795609 3 0 3 \n",
"z\n",
"\" id=\"mc530b6119b\" style=\"stroke:#348abd;\"/>\n",
" </defs>\n",
" <g clip-path=\"url(#p07d0391b70)\">\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"48.238182\" xlink:href=\"#mc530b6119b\" y=\"101.919923\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"200.42\" xlink:href=\"#mc530b6119b\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"352.601818\" xlink:href=\"#mc530b6119b\" y=\"107.352789\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"line2d_22\">\n",
" <path clip-path=\"url(#p07d0391b70)\" d=\"M 48.238182 214.756364 \n",
"L 352.601818 214.756364 \n",
"\" style=\"fill:none;stroke:#467821;stroke-linecap:square;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"patch_3\">\n",
" <path d=\"M 33.02 224.64 \n",
"L 33.02 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_4\">\n",
" <path d=\"M 367.82 224.64 \n",
"L 367.82 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_5\">\n",
" <path d=\"M 33.02 224.64 \n",
"L 367.82 224.64 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_6\">\n",
" <path d=\"M 33.02 7.2 \n",
"L 367.82 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <defs>\n",
" <clipPath id=\"p07d0391b70\">\n",
" <rect height=\"217.44\" width=\"334.8\" x=\"33.02\" y=\"7.2\"/>\n",
" </clipPath>\n",
" </defs>\n",
"</svg>\n"
],
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"values, counts = numpy.unique(heads, return_counts=True)\n",
"plt.stem(values, counts, use_line_collection=True)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The SymPy library, which adds symbolic mathematics capabilities to Python, has functionality that allows us to calculate the expected number of heads and the probability distribution **analytically**."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 1.0$"
],
"text/plain": [
"1.00000000000000"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sympy.stats\n",
"from sympy.interactive import printing\n",
"printing.init_printing(use_latex=\"mathjax\")\n",
"\n",
"toss1 = sympy.stats.Bernoulli(\"toss1\", p=0.5)\n",
"toss2 = sympy.stats.Bernoulli(\"toss2\", p=0.5)\n",
"sympy.stats.E(toss1 + toss2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So the **expected value** of the number of heads is 1 (the numerical approximation we estimated using our simulation above was very close to that). Now let’s examine the **probability distribution**. "
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left\\{ 0 : 0.25, \\ 1 : 0.5, \\ 2 : 0.25\\right\\}$"
],
"text/plain": [
"{0: 0.25, 1: 0.5, 2: 0.25}"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sympy.stats.density(toss1 + toss2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Expected value of a dice roll"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The expected value of a dice roll is \n",
"\n",
"$$\\sum_{i=1}^6 i \\times \\frac{1}{6} = 3.5$$\n",
"\n",
"That means that if we toss a dice a large number of times, the mean value should converge to 3.5. Let’s check that empirically by running a simulation in Python."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
"<svg height=\"266.31825pt\" version=\"1.1\" viewBox=\"0 0 360.14 266.31825\" width=\"360.14pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
" <metadata>\n",
" <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
" <cc:Work>\n",
" <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
" <dc:date>2020-10-02T13:10:21.339536</dc:date>\n",
" <dc:format>image/svg+xml</dc:format>\n",
" <dc:creator>\n",
" <cc:Agent>\n",
" <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n",
" </cc:Agent>\n",
" </dc:creator>\n",
" </cc:Work>\n",
" </rdf:RDF>\n",
" </metadata>\n",
" <defs>\n",
" <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
" </defs>\n",
" <g id=\"figure_1\">\n",
" <g id=\"patch_1\">\n",
" <path d=\"M 0 266.31825 \n",
"L 360.14 266.31825 \n",
"L 360.14 0 \n",
"L 0 0 \n",
"z\n",
"\" style=\"fill:none;\"/>\n",
" </g>\n",
" <g id=\"axes_1\">\n",
" <g id=\"patch_2\">\n",
" <path d=\"M 18.14 240.69075 \n",
"L 352.94 240.69075 \n",
"L 352.94 23.25075 \n",
"L 18.14 23.25075 \n",
"z\n",
"\" style=\"fill:#eeeeee;\"/>\n",
" </g>\n",
" <g id=\"matplotlib.axis_1\">\n",
" <g id=\"xtick_1\">\n",
" <g id=\"line2d_1\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 33.358182 240.69075 \n",
"L 33.358182 23.25075 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_2\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 0 -3.5 \n",
"\" id=\"m3198d90499\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"33.358182\" xlink:href=\"#m3198d90499\" y=\"240.69075\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_1\">\n",
" <!-- 0 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(29.638182 255.35825)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 22.796875 -1 \n",
"C 30.5 -1 42.09375 7.5 42.09375 30.90625 \n",
"C 42.09375 46.5 36.40625 54.203125 32.796875 57.5 \n",
"C 30.09375 60 26.90625 61 23.296875 61 \n",
"C 13.296875 61 3.90625 48.59375 3.90625 28.90625 \n",
"C 3.90625 12.703125 10.40625 -1 22.796875 -1 \n",
"z\n",
"M 23.296875 57.09375 \n",
"C 25 57.09375 26.59375 56.5 27.703125 55.5 \n",
"C 30.796875 52.90625 33.5 45.09375 33.5 31.703125 \n",
"C 33.5 22.5 33.203125 17.296875 31.796875 12.203125 \n",
"C 29.59375 3.90625 24.703125 2.90625 22.90625 2.90625 \n",
"C 13.59375 2.90625 12.5 20 12.5 28.703125 \n",
"C 12.5 53.40625 18.703125 57.09375 23.296875 57.09375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-48\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_2\">\n",
" <g id=\"line2d_3\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 94.291843 240.69075 \n",
"L 94.291843 23.25075 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_4\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"94.291843\" xlink:href=\"#m3198d90499\" y=\"240.69075\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_2\">\n",
" <!-- 200 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(83.131843 255.35825)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 22.203125 55.296875 \n",
"C 27.40625 55.296875 32.796875 50.5 32.796875 43.5 \n",
"C 32.796875 39.296875 31.59375 34 29 30.09375 \n",
"C 21.796875 19.40625 10.40625 9.40625 5.40625 4.703125 \n",
"C 5.296875 4.296875 5.296875 3.90625 5.296875 3.40625 \n",
"C 5.296875 1.90625 5.796875 0.40625 6.296875 -0.5 \n",
"C 13.703125 -0.296875 17.90625 0 25.203125 0 \n",
"C 32.40625 0 35.40625 -0.203125 42.59375 -0.5 \n",
"C 42.40625 0.5 42.296875 1.703125 42.296875 2.796875 \n",
"C 42.296875 4.40625 42.40625 6 42.796875 7.5 \n",
"C 37.09375 7 34.09375 6.703125 24.5 6.703125 \n",
"C 21 6.703125 19 6.703125 16.296875 6.5 \n",
"C 16.203125 6.703125 16.203125 6.796875 16.203125 7 \n",
"C 16.203125 7.90625 17.203125 9 17.90625 9.703125 \n",
"C 22.796875 14.40625 27.5 18.90625 34.09375 27.796875 \n",
"C 37.796875 32.796875 41.40625 39.203125 41.40625 44.90625 \n",
"C 41.40625 54.40625 35 61 23.796875 61 \n",
"C 14.703125 61 8.90625 55.90625 6.59375 52.90625 \n",
"L 8.796875 46 \n",
"L 10.09375 45.90625 \n",
"C 11.5 48.90625 12 51 14.5 53 \n",
"C 16.5 54.59375 19.40625 55.296875 22.203125 55.296875 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-50\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_3\">\n",
" <g id=\"line2d_5\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 155.225504 240.69075 \n",
"L 155.225504 23.25075 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_6\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"155.225504\" xlink:href=\"#m3198d90499\" y=\"240.69075\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_3\">\n",
" <!-- 400 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(144.065504 255.35825)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 28.59375 14.796875 \n",
"C 28.59375 7.09375 28.40625 5.09375 27.796875 0 \n",
"L 27.90625 -0.296875 \n",
"C 27.90625 -0.296875 31 0 32.59375 0 \n",
"C 34.203125 0 35.90625 -0.296875 36.796875 -0.296875 \n",
"C 36.90625 -0.296875 37 -0.09375 37 0 \n",
"C 36.59375 5.796875 36.40625 9 36.40625 14.796875 \n",
"L 41.40625 14.796875 \n",
"C 42.796875 14.796875 44.296875 17.09375 44.296875 18.203125 \n",
"C 44.296875 19.09375 43.796875 19.796875 42.796875 19.796875 \n",
"L 36.40625 19.796875 \n",
"L 36.40625 45.203125 \n",
"C 36.40625 48.5 36.5 55.40625 37 60 \n",
"C 37 60.203125 36.90625 60.40625 36.796875 60.40625 \n",
"C 35.90625 60.40625 34.40625 60 32.90625 60 \n",
"C 31.296875 60 29.5 60.40625 29.5 60.40625 \n",
"C 29.5 60.40625 29.09375 60.09375 29.09375 60 \n",
"C 23 51.59375 8.59375 29.59375 3.40625 20.703125 \n",
"C 2.40625 18.90625 2.09375 17.796875 2.09375 16.796875 \n",
"C 2.09375 15.296875 4.40625 14.796875 8 14.796875 \n",
"z\n",
"M 28.59375 51.203125 \n",
"L 28.59375 19.796875 \n",
"L 8.296875 19.796875 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-52\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-52\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_4\">\n",
" <g id=\"line2d_7\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 216.159165 240.69075 \n",
"L 216.159165 23.25075 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_8\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"216.159165\" xlink:href=\"#m3198d90499\" y=\"240.69075\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_4\">\n",
" <!-- 600 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(204.999165 255.35825)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 40 58.296875 \n",
"L 39.703125 61.09375 \n",
"C 29.40625 60.5 22.09375 57.703125 15.296875 50.796875 \n",
"C 8 43.5 4.59375 34 4.59375 24.296875 \n",
"C 4.59375 3.296875 16.703125 -0.90625 24.40625 -0.90625 \n",
"C 39 -0.90625 43.203125 10.796875 43.203125 18 \n",
"C 43.203125 22.796875 40.5 35.796875 24.90625 35.796875 \n",
"C 20.90625 35.796875 15.296875 33.59375 12.90625 30.59375 \n",
"C 14 39.09375 17.59375 46.203125 22.40625 50.90625 \n",
"C 27.5 55.796875 33.09375 57.59375 40 58.296875 \n",
"z\n",
"M 12.703125 27.703125 \n",
"C 16.59375 31.703125 20.59375 31.796875 22.796875 31.796875 \n",
"C 32.90625 31.796875 34.40625 22.203125 34.40625 17.296875 \n",
"C 34.40625 6.296875 30.296875 2.703125 25.5 2.703125 \n",
"C 20.203125 2.703125 12.59375 6.203125 12.59375 24 \n",
"C 12.59375 25 12.59375 26.703125 12.703125 27.703125 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-54\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-54\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_5\">\n",
" <g id=\"line2d_9\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 277.092826 240.69075 \n",
"L 277.092826 23.25075 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_10\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"277.092826\" xlink:href=\"#m3198d90499\" y=\"240.69075\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_5\">\n",
" <!-- 800 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(265.932826 255.35825)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 39.796875 48.5 \n",
"C 39.796875 55.703125 34 61 24.09375 61 \n",
"C 13.90625 61 6.703125 55 6.703125 47.296875 \n",
"C 6.703125 41.703125 9.796875 36.703125 15.5 33.40625 \n",
"L 17.5 32.296875 \n",
"C 15 30.40625 13 28.796875 10.5 26.59375 \n",
"C 6.40625 23 3.90625 18.5 3.90625 14.59375 \n",
"C 3.90625 4.40625 12 -0.90625 22.59375 -0.90625 \n",
"C 35.703125 -0.90625 42.796875 8.59375 42.796875 16.203125 \n",
"C 42.796875 22 39.59375 26.40625 34.09375 30 \n",
"L 28 34 \n",
"C 32.5 37 39.796875 42.09375 39.796875 48.5 \n",
"z\n",
"M 22.796875 2.40625 \n",
"C 18.203125 2.40625 11.703125 5.59375 11.703125 14.59375 \n",
"C 11.703125 17.59375 12.5 24.296875 21.09375 30 \n",
"L 25.703125 27.09375 \n",
"C 31.90625 23.203125 34.5 18.796875 34.5 14.09375 \n",
"C 34.5 4.40625 27.40625 2.40625 22.796875 2.40625 \n",
"z\n",
"M 23.5 57.703125 \n",
"C 30 57.703125 32.40625 53.296875 32.40625 48.59375 \n",
"C 32.40625 43.203125 27.09375 38.40625 24.296875 36.40625 \n",
"L 21.203125 38.203125 \n",
"C 14.90625 42.296875 14.203125 46 14.203125 49.09375 \n",
"C 14.203125 53.796875 17.5 57.703125 23.5 57.703125 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-56\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-56\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_6\">\n",
" <g id=\"line2d_11\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 338.026486 240.69075 \n",
"L 338.026486 23.25075 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_12\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"338.026486\" xlink:href=\"#m3198d90499\" y=\"240.69075\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_6\">\n",
" <!-- 1000 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(323.146486 255.35825)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 28.59375 18.90625 \n",
"L 28.59375 44.296875 \n",
"C 28.59375 55.09375 29.203125 59.09375 29.40625 60.5 \n",
"C 29.40625 61 29.09375 61 28.703125 61 \n",
"C 22.203125 58.90625 14.59375 55 6.796875 52.59375 \n",
"L 7.40625 49.703125 \n",
"C 11.90625 50.203125 16.796875 51.296875 18.796875 51.296875 \n",
"C 20.59375 51.296875 20.59375 47.296875 20.59375 43.703125 \n",
"L 20.59375 18.90625 \n",
"C 20.59375 11.09375 20.5 5.703125 19.796875 0 \n",
"L 19.90625 -0.296875 \n",
"C 19.90625 -0.296875 22.703125 0 24.5 0 \n",
"C 26.5 0 29.296875 -0.296875 29.296875 -0.296875 \n",
"L 29.5 0 \n",
"C 28.796875 6 28.59375 11 28.59375 18.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-49\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"139.499954\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"matplotlib.axis_2\">\n",
" <g id=\"ytick_1\">\n",
" <g id=\"line2d_13\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 18.14 230.807114 \n",
"L 352.94 230.807114 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_14\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 3.5 0 \n",
"\" id=\"mf0c86742a6\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"18.14\" xlink:href=\"#mf0c86742a6\" y=\"230.807114\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_7\">\n",
" <!-- 0 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 236.390864)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_2\">\n",
" <g id=\"line2d_15\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 18.14 185.19033 \n",
"L 352.94 185.19033 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_16\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"18.14\" xlink:href=\"#mf0c86742a6\" y=\"185.19033\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_8\">\n",
" <!-- 1 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 190.77408)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_3\">\n",
" <g id=\"line2d_17\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 18.14 139.573547 \n",
"L 352.94 139.573547 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_18\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"18.14\" xlink:href=\"#mf0c86742a6\" y=\"139.573547\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_9\">\n",
" <!-- 2 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 145.157297)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_4\">\n",
" <g id=\"line2d_19\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 18.14 93.956764 \n",
"L 352.94 93.956764 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_20\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"18.14\" xlink:href=\"#mf0c86742a6\" y=\"93.956764\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_10\">\n",
" <!-- 3 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 99.540514)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 20.90625 2.90625 \n",
"C 13 2.90625 11.90625 5.90625 9.203125 11.703125 \n",
"L 7.703125 11.59375 \n",
"L 5.5 4.09375 \n",
"L 5.796875 3.796875 \n",
"C 8.40625 1.59375 12.703125 -1 20.703125 -1 \n",
"C 29.203125 -1 42.59375 4.796875 42.59375 18 \n",
"C 42.59375 25.90625 36.5 31.5 28.796875 32.203125 \n",
"L 28.796875 32.703125 \n",
"C 34 33.90625 40.59375 39.703125 40.59375 48 \n",
"C 40.59375 55.203125 34.40625 61 24.5 61 \n",
"C 16.796875 61 11.203125 57.59375 8.703125 55.40625 \n",
"L 8.40625 55.09375 \n",
"L 10.5 48.703125 \n",
"L 12 48.59375 \n",
"C 14.40625 54.203125 17.59375 57.09375 23.59375 57.09375 \n",
"C 27.5 57.09375 31.90625 53 31.90625 46.5 \n",
"C 31.90625 42.09375 30.40625 38.90625 28.09375 36.703125 \n",
"C 26.09375 34.796875 23.203125 33.90625 19.796875 33.90625 \n",
"C 18.59375 33.90625 17.5 34 16.09375 34.203125 \n",
"L 16.09375 29.796875 \n",
"C 17.296875 30 19.40625 30 20.296875 30 \n",
"C 23.5 30 27.296875 29.09375 30.09375 26.796875 \n",
"C 32.703125 24.59375 34 21.09375 34 17.203125 \n",
"C 34 5.09375 24.5 2.90625 20.90625 2.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-51\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-51\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_5\">\n",
" <g id=\"line2d_21\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 18.14 48.339981 \n",
"L 352.94 48.339981 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_22\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"18.14\" xlink:href=\"#mf0c86742a6\" y=\"48.339981\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_11\">\n",
" <!-- 4 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 53.923731)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-52\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"line2d_23\">\n",
" <path clip-path=\"url(#p342541b8ee)\" d=\"M 33.358182 230.807114 \n",
"L 33.66285 93.956764 \n",
"L 33.967518 48.339981 \n",
"L 34.272187 93.956764 \n",
"L 35.186192 33.134386 \n",
"L 35.49086 54.856664 \n",
"L 36.100197 78.75117 \n",
"L 36.404865 75.710051 \n",
"L 36.709533 77.368843 \n",
"L 37.014201 82.552568 \n",
"L 37.31887 90.447781 \n",
"L 37.623538 84.181739 \n",
"L 38.232875 91.105715 \n",
"L 38.537543 96.640104 \n",
"L 38.842211 99.025295 \n",
"L 39.451548 87.114247 \n",
"L 39.756216 89.612308 \n",
"L 40.060885 83.589313 \n",
"L 40.365553 80.073395 \n",
"L 40.670221 84.453267 \n",
"L 40.974889 84.833407 \n",
"L 41.279558 86.938797 \n",
"L 41.584226 87.198722 \n",
"L 41.888894 84.181739 \n",
"L 42.193563 86.091801 \n",
"L 42.498231 81.792288 \n",
"L 42.802899 80.713182 \n",
"L 43.107568 81.127044 \n",
"L 43.412236 82.89815 \n",
"L 43.716904 83.223403 \n",
"L 44.021572 84.833407 \n",
"L 44.326241 87.6211 \n",
"L 44.630909 84.093676 \n",
"L 44.935577 84.353231 \n",
"L 45.544914 82.552568 \n",
"L 45.849582 80.60551 \n",
"L 46.154251 82.009511 \n",
"L 46.458919 82.287354 \n",
"L 46.763587 80.479078 \n",
"L 47.068256 80.778582 \n",
"L 47.372924 82.056734 \n",
"L 47.677592 81.339356 \n",
"L 47.98226 83.502918 \n",
"L 48.286929 82.785307 \n",
"L 48.591597 81.184065 \n",
"L 48.896265 78.75117 \n",
"L 49.200934 80.798077 \n",
"L 49.505602 79.324966 \n",
"L 49.81027 80.44068 \n",
"L 50.114939 82.345219 \n",
"L 50.419607 80.923397 \n",
"L 50.724275 81.952347 \n",
"L 51.028943 81.372824 \n",
"L 51.333612 79.266613 \n",
"L 51.63828 80.271729 \n",
"L 51.942948 80.496074 \n",
"L 52.552285 82.371549 \n",
"L 52.856953 80.414281 \n",
"L 53.161622 80.622627 \n",
"L 53.770958 78.297271 \n",
"L 54.075627 79.198393 \n",
"L 54.684963 79.620061 \n",
"L 54.989631 77.894516 \n",
"L 55.2943 77.484037 \n",
"L 55.598968 76.459916 \n",
"L 55.903636 74.84703 \n",
"L 56.208305 76.318274 \n",
"L 56.512973 75.349918 \n",
"L 56.817641 73.814288 \n",
"L 57.12231 72.902864 \n",
"L 57.426978 72.591941 \n",
"L 57.731646 73.999421 \n",
"L 58.036314 73.682638 \n",
"L 58.340983 75.042488 \n",
"L 58.645651 75.819971 \n",
"L 58.950319 74.406714 \n",
"L 59.254988 75.710051 \n",
"L 59.559656 75.391794 \n",
"L 59.864324 74.556523 \n",
"L 60.168993 75.813725 \n",
"L 60.473661 74.479935 \n",
"L 60.778329 75.710051 \n",
"L 61.082998 75.910564 \n",
"L 61.387666 75.115049 \n",
"L 61.997002 72.604227 \n",
"L 62.301671 73.309167 \n",
"L 62.606339 73.049072 \n",
"L 62.911007 73.734891 \n",
"L 63.215676 72.544805 \n",
"L 63.520344 71.839536 \n",
"L 64.129681 74.084106 \n",
"L 64.434349 73.384489 \n",
"L 64.739017 72.255576 \n",
"L 65.653022 75.451842 \n",
"L 66.262359 74.949771 \n",
"L 66.567027 75.124147 \n",
"L 66.871695 75.710051 \n",
"L 67.7857 73.772347 \n",
"L 68.090369 73.949403 \n",
"L 68.395037 73.726712 \n",
"L 69.004373 71.733203 \n",
"L 69.309042 71.921538 \n",
"L 69.61371 70.956705 \n",
"L 69.918378 70.388093 \n",
"L 70.223047 70.959873 \n",
"L 70.527715 71.896188 \n",
"L 71.137052 71.51625 \n",
"L 71.44172 71.695774 \n",
"L 71.746388 71.51041 \n",
"L 72.051057 70.968779 \n",
"L 72.355725 70.079229 \n",
"L 72.660393 69.557089 \n",
"L 72.965061 69.744779 \n",
"L 73.26973 69.233164 \n",
"L 73.574398 68.383719 \n",
"L 73.879066 68.918981 \n",
"L 74.183735 69.10583 \n",
"L 74.488403 69.627813 \n",
"L 74.793071 70.477537 \n",
"L 75.09774 70.981888 \n",
"L 75.707076 72.625175 \n",
"L 76.011744 73.103377 \n",
"L 76.316413 73.251274 \n",
"L 76.621081 72.433352 \n",
"L 77.230418 71.465156 \n",
"L 77.535086 70.676475 \n",
"L 78.144423 72.234486 \n",
"L 78.449091 72.381258 \n",
"L 78.753759 72.219908 \n",
"L 79.058428 72.668932 \n",
"L 79.363096 73.414107 \n",
"L 79.667764 72.949035 \n",
"L 79.972432 73.08634 \n",
"L 80.277101 73.518075 \n",
"L 80.581769 73.649938 \n",
"L 81.191106 74.489729 \n",
"L 81.495774 73.746797 \n",
"L 81.800442 74.447699 \n",
"L 82.409779 74.690048 \n",
"L 82.714447 73.964223 \n",
"L 83.323784 73.09543 \n",
"L 83.93312 74.445971 \n",
"L 84.237789 74.289648 \n",
"L 84.542457 73.592129 \n",
"L 84.847125 73.172786 \n",
"L 85.151794 73.563379 \n",
"L 85.456462 73.682638 \n",
"L 85.76113 74.330939 \n",
"L 86.370467 74.556523 \n",
"L 86.675135 74.406714 \n",
"L 86.979803 73.999421 \n",
"L 87.284472 74.627619 \n",
"L 87.58914 74.736209 \n",
"L 87.893808 75.353271 \n",
"L 88.198477 75.710051 \n",
"L 88.503145 75.558835 \n",
"L 88.807813 75.910564 \n",
"L 89.41715 77.098388 \n",
"L 89.721818 76.69636 \n",
"L 90.331155 76.880963 \n",
"L 90.635823 77.214434 \n",
"L 90.940491 77.061659 \n",
"L 91.24516 76.430316 \n",
"L 91.549828 76.522077 \n",
"L 91.854496 76.137708 \n",
"L 92.463833 76.791686 \n",
"L 93.07317 75.803146 \n",
"L 93.377838 75.663739 \n",
"L 93.682506 75.295353 \n",
"L 93.987174 75.159899 \n",
"L 94.596511 74.439135 \n",
"L 94.901179 74.987409 \n",
"L 95.205848 75.305567 \n",
"L 95.510516 74.949771 \n",
"L 96.119853 74.027101 \n",
"L 96.424521 74.12338 \n",
"L 96.729189 74.438044 \n",
"L 97.033857 74.531435 \n",
"L 97.338526 74.84116 \n",
"L 97.643194 74.931755 \n",
"L 98.252531 74.25374 \n",
"L 98.557199 74.772136 \n",
"L 98.861867 74.224853 \n",
"L 99.166536 74.316205 \n",
"L 99.471204 74.196498 \n",
"L 99.775872 74.705644 \n",
"L 100.385209 74.880655 \n",
"L 100.689877 75.379793 \n",
"L 100.994545 75.052511 \n",
"L 101.299214 75.137284 \n",
"L 101.603882 74.814007 \n",
"L 101.90855 75.304568 \n",
"L 102.213219 74.983412 \n",
"L 102.517887 75.26795 \n",
"L 102.822555 75.149845 \n",
"L 103.127224 75.231971 \n",
"L 103.431892 74.718381 \n",
"L 103.73656 74.604189 \n",
"L 104.041229 74.294357 \n",
"L 104.345897 74.378745 \n",
"L 104.650565 74.072525 \n",
"L 104.955233 74.351253 \n",
"L 105.259902 74.82091 \n",
"L 105.56457 74.901652 \n",
"L 106.173907 75.442839 \n",
"L 106.478575 75.519981 \n",
"L 106.783243 75.217919 \n",
"L 107.087912 74.729855 \n",
"L 107.39258 74.996702 \n",
"L 107.697248 74.887453 \n",
"L 108.001916 75.151478 \n",
"L 108.611253 74.380331 \n",
"L 108.915921 74.091391 \n",
"L 109.22059 73.987971 \n",
"L 109.525258 74.250314 \n",
"L 109.829926 73.965345 \n",
"L 110.134595 73.501619 \n",
"L 110.439263 73.58247 \n",
"L 111.353268 74.890374 \n",
"L 111.657936 75.14206 \n",
"L 111.962604 75.038176 \n",
"L 112.267273 74.758967 \n",
"L 112.571941 74.832805 \n",
"L 112.876609 74.381746 \n",
"L 113.181278 74.45646 \n",
"L 113.485946 74.010262 \n",
"L 113.790614 74.258608 \n",
"L 114.399951 74.921189 \n",
"L 115.009287 74.722822 \n",
"L 115.618624 74.02054 \n",
"L 115.923292 73.75745 \n",
"L 116.227961 73.328586 \n",
"L 117.141966 73.055983 \n",
"L 117.446634 73.296989 \n",
"L 117.751302 73.206891 \n",
"L 118.055971 73.281531 \n",
"L 118.360639 73.682638 \n",
"L 118.665307 73.592129 \n",
"L 118.969975 73.177589 \n",
"L 119.579312 73.808008 \n",
"L 119.88398 73.397087 \n",
"L 120.188649 73.789344 \n",
"L 120.493317 73.381362 \n",
"L 120.797985 73.611997 \n",
"L 121.102654 73.682638 \n",
"L 121.71199 74.137058 \n",
"L 122.321327 73.4917 \n",
"L 122.930663 73.3206 \n",
"L 123.54 73.460034 \n",
"L 123.844668 73.375454 \n",
"L 124.149337 73.138366 \n",
"L 124.454005 73.055429 \n",
"L 124.758673 72.820988 \n",
"L 125.063342 72.891206 \n",
"L 125.36801 73.263058 \n",
"L 125.672678 72.879702 \n",
"L 126.282015 73.017913 \n",
"L 127.19602 73.666182 \n",
"L 127.500688 73.288966 \n",
"L 127.805356 73.502787 \n",
"L 128.110025 73.2752 \n",
"L 128.414693 73.195279 \n",
"L 128.719361 73.553091 \n",
"L 129.024029 73.618071 \n",
"L 129.328698 73.393008 \n",
"L 129.633366 73.746797 \n",
"L 130.242703 73.300107 \n",
"L 130.547371 73.364862 \n",
"L 130.852039 73.286659 \n",
"L 131.156708 73.49316 \n",
"L 131.461376 73.131711 \n",
"L 131.766044 73.054956 \n",
"L 132.070713 72.69709 \n",
"L 132.984717 72.892133 \n",
"L 133.289386 73.234506 \n",
"L 133.594054 72.881533 \n",
"L 134.203391 72.733246 \n",
"L 135.117396 72.104413 \n",
"L 135.422064 72.169644 \n",
"L 135.726732 72.098722 \n",
"L 136.0314 71.757499 \n",
"L 136.336069 71.823177 \n",
"L 136.640737 72.157593 \n",
"L 136.945405 71.953374 \n",
"L 137.554742 72.082049 \n",
"L 138.164079 72.607049 \n",
"L 138.468747 72.536709 \n",
"L 138.773415 72.203096 \n",
"L 139.078084 72.397247 \n",
"L 139.382752 72.197034 \n",
"L 139.68742 72.259383 \n",
"L 140.296757 72.902864 \n",
"L 140.601425 72.833083 \n",
"L 140.906093 73.02215 \n",
"L 141.210762 72.952426 \n",
"L 141.51543 73.011593 \n",
"L 141.820098 72.942291 \n",
"L 142.124767 72.617821 \n",
"L 142.734103 73.244965 \n",
"L 143.34344 72.854263 \n",
"L 143.648108 72.912557 \n",
"L 143.952776 72.593532 \n",
"L 144.257445 72.777543 \n",
"L 144.562113 72.710591 \n",
"L 144.866781 72.768641 \n",
"L 145.780786 72.322788 \n",
"L 146.085455 72.25797 \n",
"L 146.694791 72.497256 \n",
"L 146.999459 72.432491 \n",
"L 147.304128 72.124132 \n",
"L 147.608796 72.425642 \n",
"L 148.218133 71.813869 \n",
"L 148.522801 72.113807 \n",
"L 148.827469 71.810357 \n",
"L 149.741474 71.626035 \n",
"L 150.046143 71.922548 \n",
"L 150.350811 71.623547 \n",
"L 150.655479 71.918526 \n",
"L 150.960147 71.857442 \n",
"L 151.874152 71.089739 \n",
"L 152.178821 70.91444 \n",
"L 152.788157 71.148372 \n",
"L 153.092826 70.974263 \n",
"L 153.397494 71.264151 \n",
"L 153.702162 71.09063 \n",
"L 154.00683 71.263566 \n",
"L 154.311499 70.976017 \n",
"L 154.616167 71.148372 \n",
"L 155.225504 70.578163 \n",
"L 155.530172 70.636463 \n",
"L 155.83484 70.467525 \n",
"L 156.444177 71.03546 \n",
"L 156.748845 70.979421 \n",
"L 157.053514 70.698946 \n",
"L 157.358182 70.980252 \n",
"L 157.66285 71.036567 \n",
"L 157.967518 70.758009 \n",
"L 158.272187 70.814591 \n",
"L 158.881523 71.369813 \n",
"L 159.186192 71.314051 \n",
"L 159.49086 71.589114 \n",
"L 160.404865 70.765498 \n",
"L 161.014201 70.658455 \n",
"L 161.623538 71.094196 \n",
"L 161.928206 71.256469 \n",
"L 162.232875 71.202293 \n",
"L 163.756216 72.427348 \n",
"L 164.365553 71.997057 \n",
"L 164.670221 72.259686 \n",
"L 165.279558 72.043852 \n",
"L 165.584226 72.19945 \n",
"L 165.888894 71.934869 \n",
"L 166.193563 72.090003 \n",
"L 166.498231 71.826883 \n",
"L 166.802899 71.981556 \n",
"L 167.107568 71.719881 \n",
"L 168.326241 72.332555 \n",
"L 168.630909 72.278518 \n",
"L 168.935577 72.532252 \n",
"L 169.240246 72.580289 \n",
"L 169.544914 72.424009 \n",
"L 170.154251 72.519924 \n",
"L 170.458919 72.263449 \n",
"L 170.763587 72.513841 \n",
"L 171.068256 72.258515 \n",
"L 171.98226 72.902864 \n",
"L 172.286929 72.848998 \n",
"L 172.591597 72.995004 \n",
"L 172.896265 72.941172 \n",
"L 173.200934 72.688808 \n",
"L 173.505602 72.635876 \n",
"L 173.81027 72.38527 \n",
"L 174.724275 72.426429 \n",
"L 175.028943 72.37463 \n",
"L 175.333612 72.127273 \n",
"L 175.63828 72.271698 \n",
"L 175.942948 72.025618 \n",
"L 176.856953 72.45586 \n",
"L 177.161622 72.404767 \n",
"L 177.46629 72.546773 \n",
"L 177.770958 72.303228 \n",
"L 178.380295 72.490042 \n",
"L 178.684963 72.248148 \n",
"L 179.598968 72.003687 \n",
"L 179.903636 72.239002 \n",
"L 180.208305 72.094779 \n",
"L 181.12231 72.324063 \n",
"L 181.426978 72.086989 \n",
"L 182.036314 71.896188 \n",
"L 182.645651 71.61385 \n",
"L 183.559656 71.749811 \n",
"L 183.864324 71.517739 \n",
"L 184.473661 71.700188 \n",
"L 185.082998 71.331572 \n",
"L 185.387666 71.559746 \n",
"L 187.215676 71.825849 \n",
"L 188.129681 71.327966 \n",
"L 188.434349 71.551664 \n",
"L 188.739017 71.506151 \n",
"L 189.043686 71.728625 \n",
"L 189.653022 71.370676 \n",
"L 189.95769 71.503367 \n",
"L 190.871695 71.192489 \n",
"L 191.7857 71.060648 \n",
"L 192.090369 70.841926 \n",
"L 192.699705 70.755876 \n",
"L 194.527715 71.450185 \n",
"L 194.832383 71.320511 \n",
"L 195.137052 71.449048 \n",
"L 195.44172 71.40561 \n",
"L 196.051057 71.660921 \n",
"L 196.355725 71.61733 \n",
"L 196.660393 71.40369 \n",
"L 197.26973 71.57232 \n",
"L 197.879066 71.739701 \n",
"L 198.488403 71.400864 \n",
"L 199.402408 71.273923 \n",
"L 199.707076 71.399014 \n",
"L 200.011744 71.273464 \n",
"L 200.316413 71.481342 \n",
"L 201.230418 71.603712 \n",
"L 201.535086 71.39629 \n",
"L 201.839754 71.519576 \n",
"L 202.144423 71.477735 \n",
"L 202.753759 71.066328 \n",
"L 203.058428 71.189321 \n",
"L 204.277101 70.619836 \n",
"L 204.581769 70.823698 \n",
"L 205.191106 70.420445 \n",
"L 205.800442 70.261827 \n",
"L 206.105111 70.062258 \n",
"L 206.409779 70.264949 \n",
"L 206.714447 70.226416 \n",
"L 207.019115 70.348078 \n",
"L 207.323784 70.149756 \n",
"L 207.628452 70.350876 \n",
"L 207.93312 70.392073 \n",
"L 208.542457 70.791371 \n",
"L 208.847125 70.752393 \n",
"L 209.456462 70.911607 \n",
"L 210.065799 70.676475 \n",
"L 210.370467 70.873572 \n",
"L 211.58914 70.719497 \n",
"L 212.198477 70.876381 \n",
"L 212.807813 70.490066 \n",
"L 213.112482 70.607156 \n",
"L 213.41715 70.492293 \n",
"L 213.721818 70.608985 \n",
"L 214.026486 70.571432 \n",
"L 214.331155 70.380413 \n",
"L 214.940491 70.765681 \n",
"L 215.549828 70.614397 \n",
"L 216.463833 70.806816 \n",
"L 216.768501 70.996822 \n",
"L 217.07317 70.807949 \n",
"L 217.682506 70.733674 \n",
"L 217.987174 70.922547 \n",
"L 218.291843 70.960494 \n",
"L 219.510516 70.588428 \n",
"L 220.119853 70.962333 \n",
"L 220.729189 70.888765 \n",
"L 221.033857 70.704053 \n",
"L 222.252531 70.559769 \n",
"L 222.557199 70.670902 \n",
"L 222.861867 70.488322 \n",
"L 223.471204 70.782853 \n",
"L 224.080541 70.638281 \n",
"L 224.385209 70.748225 \n",
"L 224.689877 70.639905 \n",
"L 224.994545 70.82202 \n",
"L 225.299214 70.858742 \n",
"L 225.90855 70.570945 \n",
"L 226.213219 70.46376 \n",
"L 226.517887 70.500816 \n",
"L 226.822555 70.394079 \n",
"L 227.431892 70.754507 \n",
"L 227.73656 70.790874 \n",
"L 228.041229 70.612964 \n",
"L 228.345897 70.578163 \n",
"L 228.650565 70.6858 \n",
"L 229.56457 70.652538 \n",
"L 230.173907 70.724687 \n",
"L 230.478575 70.549079 \n",
"L 231.39258 70.937833 \n",
"L 231.697248 70.833049 \n",
"L 232.001916 71.008444 \n",
"L 232.915921 71.11355 \n",
"L 233.22059 70.939759 \n",
"L 233.525258 70.905361 \n",
"L 234.134595 70.629213 \n",
"L 234.439263 70.595442 \n",
"L 235.0486 70.803835 \n",
"L 235.353268 70.769953 \n",
"L 235.657936 70.873572 \n",
"L 235.962604 70.771091 \n",
"L 236.267273 70.942891 \n",
"L 237.181278 70.568787 \n",
"L 237.485946 70.39944 \n",
"L 239.009287 70.911841 \n",
"L 239.313956 70.74349 \n",
"L 240.532629 71.215456 \n",
"L 240.837297 71.38282 \n",
"L 241.446634 71.382133 \n",
"L 241.751302 71.54852 \n",
"L 242.055971 71.381451 \n",
"L 242.360639 71.347863 \n",
"L 242.969975 71.6788 \n",
"L 243.274644 71.711134 \n",
"L 243.88398 71.445443 \n",
"L 244.188649 71.346133 \n",
"L 244.797985 71.608484 \n",
"L 245.102654 71.443733 \n",
"L 245.407322 71.410538 \n",
"L 246.016658 71.605847 \n",
"L 246.321327 71.442043 \n",
"L 247.54 72.089259 \n",
"L 247.844668 71.990728 \n",
"L 248.149337 72.151295 \n",
"L 248.758673 71.954893 \n",
"L 249.063342 72.11483 \n",
"L 249.977346 72.20699 \n",
"L 250.586683 71.948106 \n",
"L 250.891351 71.787263 \n",
"L 251.19602 71.754469 \n",
"L 251.500688 71.594347 \n",
"L 251.805356 71.625535 \n",
"L 252.110025 71.466038 \n",
"L 252.719361 71.655226 \n",
"L 253.024029 71.559619 \n",
"L 253.328698 71.717003 \n",
"L 253.633366 71.747763 \n",
"L 253.938034 71.652425 \n",
"L 254.242703 71.68319 \n",
"L 254.547371 71.839536 \n",
"L 255.156708 71.524335 \n",
"L 255.461376 71.680255 \n",
"L 255.766044 71.585794 \n",
"L 256.070713 71.741203 \n",
"L 256.375381 71.709234 \n",
"L 256.680049 71.801819 \n",
"L 256.984717 71.707706 \n",
"L 257.594054 71.706186 \n",
"L 257.898722 71.612587 \n",
"L 259.117396 72.225692 \n",
"L 259.726732 72.222792 \n",
"L 260.0314 72.068066 \n",
"L 260.640737 72.187897 \n",
"L 260.945405 72.217039 \n",
"L 261.554742 71.909667 \n",
"L 262.164079 72.089864 \n",
"L 262.468747 71.93696 \n",
"L 263.078084 72.116368 \n",
"L 263.382752 72.024456 \n",
"L 263.992088 72.202922 \n",
"L 264.601425 72.019839 \n",
"L 265.210762 71.837719 \n",
"L 266.124767 72.04399 \n",
"L 266.429435 71.953374 \n",
"L 266.734103 72.041651 \n",
"L 267.34344 71.920531 \n",
"L 268.257445 71.769613 \n",
"L 268.562113 71.621085 \n",
"L 268.866781 71.708993 \n",
"L 269.476118 71.707546 \n",
"L 269.780786 71.736218 \n",
"L 270.390123 71.558806 \n",
"L 270.694791 71.587558 \n",
"L 271.304128 71.469617 \n",
"L 271.608796 71.61504 \n",
"L 272.218133 71.61385 \n",
"L 272.827469 71.612665 \n",
"L 274.046143 71.321601 \n",
"L 274.350811 71.407886 \n",
"L 274.960147 71.177135 \n",
"L 275.874152 71.033757 \n",
"L 276.178821 70.890812 \n",
"L 276.483489 70.919717 \n",
"L 277.092826 70.806247 \n",
"L 278.00683 70.892737 \n",
"L 278.311499 70.751211 \n",
"L 279.530172 70.979003 \n",
"L 279.83484 70.951019 \n",
"L 280.444177 71.176496 \n",
"L 280.748845 71.036016 \n",
"L 281.66285 71.120387 \n",
"L 281.967518 71.036567 \n",
"L 282.576855 71.259905 \n",
"L 282.881523 71.176221 \n",
"L 283.49086 71.231716 \n",
"L 284.404865 71.037652 \n",
"L 284.709533 70.899554 \n",
"L 285.014201 71.03792 \n",
"L 286.842211 70.819405 \n",
"L 287.756216 70.465486 \n",
"L 288.060885 70.43902 \n",
"L 289.279558 70.876844 \n",
"L 291.412236 71.336871 \n",
"L 292.021572 71.228967 \n",
"L 292.630909 71.335985 \n",
"L 293.544914 71.362034 \n",
"L 294.154251 71.574697 \n",
"L 295.372924 71.784886 \n",
"L 295.677592 71.863618 \n",
"L 295.98226 71.783409 \n",
"L 296.591597 71.94033 \n",
"L 297.200934 71.991177 \n",
"L 297.505602 72.121741 \n",
"L 297.81027 72.041789 \n",
"L 298.114939 72.171994 \n",
"L 298.724275 71.960152 \n",
"L 300.552285 72.058627 \n",
"L 301.161622 71.900868 \n",
"L 301.46629 72.029606 \n",
"L 301.770958 71.899159 \n",
"L 302.380295 72.104103 \n",
"L 303.903636 72.227148 \n",
"L 304.512973 72.019704 \n",
"L 305.426978 72.297731 \n",
"L 308.473661 71.931385 \n",
"L 308.778329 71.854827 \n",
"L 309.082998 71.98006 \n",
"L 309.692334 71.978226 \n",
"L 310.606339 72.251196 \n",
"L 310.911007 72.124802 \n",
"L 311.215676 72.248777 \n",
"L 312.434349 72.243972 \n",
"L 313.043686 72.291277 \n",
"L 313.653022 72.189625 \n",
"L 314.262359 72.13789 \n",
"L 314.567027 72.013263 \n",
"L 315.176364 72.110023 \n",
"L 315.7857 71.960322 \n",
"L 316.090369 71.885713 \n",
"L 316.699705 71.982228 \n",
"L 317.309042 71.735713 \n",
"L 318.223047 71.855798 \n",
"L 318.527715 71.733203 \n",
"L 319.137052 71.877852 \n",
"L 319.44172 71.949945 \n",
"L 320.355725 71.681052 \n",
"L 322.488403 71.605021 \n",
"L 322.793071 71.676567 \n",
"L 323.402408 71.435873 \n",
"L 323.707076 71.555238 \n",
"L 324.011744 71.530903 \n",
"L 324.316413 71.649918 \n",
"L 326.449091 71.432885 \n",
"L 327.058428 71.243013 \n",
"L 327.667764 71.195595 \n",
"L 328.277101 71.431121 \n",
"L 328.886437 71.242428 \n",
"L 329.495774 71.101442 \n",
"L 329.800442 70.984283 \n",
"L 330.714447 71.101634 \n",
"L 332.237789 70.939121 \n",
"L 332.847125 70.80033 \n",
"L 333.456462 70.986282 \n",
"L 333.76113 70.91705 \n",
"L 334.979803 71.102295 \n",
"L 335.58914 71.240342 \n",
"L 336.503145 71.492217 \n",
"L 337.112482 71.491528 \n",
"L 337.41715 71.376913 \n",
"L 337.721818 71.445178 \n",
"L 337.721818 71.445178 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-linecap:square;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"patch_3\">\n",
" <path d=\"M 18.14 240.69075 \n",
"L 18.14 23.25075 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_4\">\n",
" <path d=\"M 352.94 240.69075 \n",
"L 352.94 23.25075 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_5\">\n",
" <path d=\"M 18.14 240.69075 \n",
"L 352.94 240.69075 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_6\">\n",
" <path d=\"M 18.14 23.25075 \n",
"L 352.94 23.25075 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"text_12\">\n",
" <!-- Expectation of a dice roll -->\n",
" <g transform=\"translate(112.21475 17.25075)scale(0.144 -0.144)\">\n",
" <defs>\n",
" <path d=\"M 19 20 \n",
"L 19 31.703125 \n",
"C 23.796875 31.703125 34.40625 31.40625 41.296875 30.703125 \n",
"L 41.59375 31 \n",
"C 41.40625 31.90625 41.296875 33.296875 41.296875 34.203125 \n",
"C 41.296875 35.09375 41.40625 36.5 41.59375 37.40625 \n",
"L 41.296875 37.703125 \n",
"C 35.40625 37.203125 30.796875 36.703125 19 36.703125 \n",
"L 19 44.5 \n",
"C 19 46.203125 19.09375 56.5 19.796875 58.90625 \n",
"C 33.203125 58.90625 47 57.703125 47 57.703125 \n",
"L 47.203125 58.09375 \n",
"C 47.09375 58.90625 47 59.796875 47 60.703125 \n",
"C 47 61.5 47.09375 63.09375 47.203125 64.5 \n",
"L 47 64.796875 \n",
"C 45.40625 64.59375 43.09375 64.5 41 64.5 \n",
"L 14.703125 64.5 \n",
"C 11.296875 64.5 9.59375 64.796875 9.59375 64.796875 \n",
"L 9.40625 64.5 \n",
"C 10.203125 58.796875 10.40625 52 10.40625 44.5 \n",
"L 10.40625 20 \n",
"C 10.40625 12.5 10.203125 5.40625 9.40625 0 \n",
"L 9.5 -0.296875 \n",
"C 9.5 -0.296875 11.203125 0 14.703125 0 \n",
"L 42 0 \n",
"C 44.09375 0 46.40625 -0.09375 48 -0.296875 \n",
"L 48.203125 0 \n",
"C 48.09375 1.40625 48 2.09375 48 3.09375 \n",
"C 48 4.09375 48.09375 5.59375 48.203125 6.40625 \n",
"L 48 6.796875 \n",
"C 48 6.796875 33.203125 5.59375 19.796875 5.59375 \n",
"C 19.09375 8 19 18.296875 19 20 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-69\"/>\n",
" <path d=\"M 18.5 20.703125 \n",
"L 2.796875 -0.296875 \n",
"C 3.796875 -0.09375 5.40625 0 6.40625 0 \n",
"C 7.40625 0 9.796875 -0.09375 10.796875 -0.296875 \n",
"C 14.59375 5.40625 17.59375 10.90625 21.59375 16.5 \n",
"C 25.59375 10.90625 28.59375 5.40625 32.203125 -0.296875 \n",
"C 33.703125 -0.09375 35.703125 0 37.296875 0 \n",
"C 38.796875 0 41.5 -0.09375 43 -0.296875 \n",
"C 37 7.5 32.09375 15.203125 26.703125 23 \n",
"L 43.09375 43.203125 \n",
"C 41.796875 43 39.59375 42.90625 38.59375 42.90625 \n",
"C 37.5 42.90625 36 43 34.90625 43.203125 \n",
"C 31.09375 37.59375 27.90625 32.296875 23.703125 26.90625 \n",
"C 19.703125 32.296875 17 37.59375 13.59375 43.203125 \n",
"C 11.90625 43 9.90625 42.90625 8.203125 42.90625 \n",
"C 6.59375 42.90625 4 43 2.40625 43.203125 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-120\"/>\n",
" <path d=\"M 16.203125 35.203125 \n",
"L 16.203125 42.5 \n",
"C 16.203125 43.296875 16.09375 43.5 15.59375 43.5 \n",
"C 13.40625 43.09375 9.796875 43 7.5 43.203125 \n",
"L 7.296875 42.90625 \n",
"C 8 38.59375 8.203125 31 8.203125 23.5 \n",
"L 8.203125 -3.203125 \n",
"C 8.203125 -10.59375 8 -17.796875 7.296875 -23.203125 \n",
"L 7.5 -23.5 \n",
"C 8.703125 -23.296875 11 -23.203125 12.203125 -23.203125 \n",
"C 13.40625 -23.203125 15.703125 -23.296875 16.90625 -23.5 \n",
"L 17.09375 -23.203125 \n",
"C 16.40625 -17.5 16.203125 -10.703125 16.203125 -3.203125 \n",
"L 16.203125 1.203125 \n",
"C 18.796875 -0.203125 22.5 -1 26.09375 -1 \n",
"C 39.296875 -1 47.296875 9 47.296875 23.09375 \n",
"C 47.296875 33.703125 41.09375 43.90625 29.90625 43.90625 \n",
"C 26 43.90625 21 41.90625 16.40625 34.90625 \n",
"z\n",
"M 16.203125 29.40625 \n",
"C 18.40625 34.703125 24.296875 39.296875 28.203125 39.296875 \n",
"C 35 39.296875 38.5 33.09375 38.5 21.796875 \n",
"C 38.5 13.59375 36.203125 3 25.5 3 \n",
"C 23.90625 3 19.703125 3.40625 16.203125 7.5 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-112\"/>\n",
" <path d=\"M 39.203125 10.40625 \n",
"C 35.703125 6.59375 31 4.90625 25.5 4.90625 \n",
"C 22.09375 4.90625 17.40625 6.203125 14.59375 10.59375 \n",
"C 12.796875 13.40625 12.203125 17.5 12.203125 23.296875 \n",
"L 39.40625 23.296875 \n",
"C 40.5 23.296875 41.203125 23.90625 41.203125 25 \n",
"C 41.203125 33.40625 37.09375 43.90625 23.90625 43.90625 \n",
"C 13.59375 43.90625 3.40625 35.59375 3.40625 20.90625 \n",
"C 3.40625 15.203125 4.59375 9.59375 7.90625 5.59375 \n",
"C 11.296875 1.5 17.09375 -1 23.796875 -1 \n",
"C 31 -1 37.40625 2.703125 41.203125 7.90625 \n",
"z\n",
"M 12.5 27.296875 \n",
"C 14.203125 37.703125 20.796875 39.90625 23.90625 39.90625 \n",
"C 27.90625 39.90625 32.296875 36.203125 32.296875 28.703125 \n",
"C 32.296875 27.796875 31.90625 27.296875 30.90625 27.296875 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-101\"/>\n",
" <path d=\"M 25 39.90625 \n",
"C 28.90625 39.90625 32.40625 37.09375 35 32.5 \n",
"L 36.296875 32.59375 \n",
"L 38.59375 40.796875 \n",
"L 38.40625 41.09375 \n",
"C 35.296875 42.703125 30.09375 43.90625 25.09375 43.90625 \n",
"C 14.703125 43.90625 3.796875 35.40625 3.796875 21.796875 \n",
"C 3.796875 7.90625 11.703125 -1 23.90625 -1 \n",
"C 29.90625 -1 34.59375 1 38.59375 6.09375 \n",
"L 36.703125 8.203125 \n",
"L 36.296875 8.203125 \n",
"C 32.5 4.796875 29.296875 4 25.59375 4 \n",
"C 18.296875 4 12.59375 10.59375 12.59375 22.296875 \n",
"C 12.59375 33.296875 18.40625 39.90625 25 39.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-99\"/>\n",
" <path d=\"M 9.5 42.90625 \n",
"C 7.5 42.90625 5.296875 42.90625 4.09375 43.09375 \n",
"C 3.40625 41.5 2.90625 40.5 1.90625 39 \n",
"L 2.40625 38.296875 \n",
"C 4.09375 38.40625 7.203125 38.5 9.5 38.5 \n",
"L 9.5 24.796875 \n",
"C 9.5 18.796875 9.203125 11.59375 9.203125 8.59375 \n",
"C 9.203125 2.09375 13.40625 -1 18 -1 \n",
"C 22.203125 -1 25.40625 0 29.59375 2.703125 \n",
"L 28.40625 5.203125 \n",
"C 25.296875 4.09375 23 4 20.5 4.40625 \n",
"C 18.09375 4.796875 17.203125 7.203125 17.203125 12.59375 \n",
"C 17.203125 15.59375 17.5 19.90625 17.5 25.90625 \n",
"L 17.5 38.5 \n",
"L 21.296875 38.5 \n",
"C 23.703125 38.5 27.203125 38.40625 28.5 38.296875 \n",
"C 28.796875 39.90625 29.09375 40.90625 29.703125 42.40625 \n",
"L 29.203125 43.09375 \n",
"C 27.40625 43 24.5 42.90625 22.203125 42.90625 \n",
"L 17.5 42.90625 \n",
"C 17.5 50.40625 17.59375 51.703125 18 57.5 \n",
"C 18 58.203125 17.703125 58.5 17.09375 58.5 \n",
"C 14.59375 57.5 13.40625 56.5 10.09375 56 \n",
"L 9.90625 55.703125 \n",
"C 9.703125 52.203125 9.5 48.703125 9.5 42.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-116\"/>\n",
" <path d=\"M 31 4.796875 \n",
"C 32.203125 0.90625 35.09375 -1 38.796875 -1 \n",
"C 41.296875 -1 44.40625 -0.40625 46.796875 2.09375 \n",
"L 46 4.59375 \n",
"C 44.90625 4.203125 44.09375 4.09375 43.296875 4.09375 \n",
"C 42.296875 4.09375 41 4.203125 40.40625 4.796875 \n",
"C 39.40625 5.703125 38.703125 8.203125 38.703125 12.59375 \n",
"C 38.703125 15.5 39 26.59375 39 27.703125 \n",
"C 39 41.203125 30.09375 43.90625 22.5 43.90625 \n",
"C 14.90625 43.90625 10.296875 40.203125 7.796875 38.09375 \n",
"L 7.5 37.703125 \n",
"L 9.203125 31 \n",
"L 10.5 30.90625 \n",
"C 13.296875 35.40625 16.703125 39.40625 21.5 39.40625 \n",
"C 25.09375 39.40625 31.09375 38.90625 31.09375 27.59375 \n",
"C 31.09375 26.90625 30.703125 26.5 30.40625 26.40625 \n",
"L 21.09375 24.296875 \n",
"C 10.90625 22 4.5 16.59375 4.5 9.796875 \n",
"C 4.5 2.40625 9.59375 -1 17 -1 \n",
"C 22.5 -1 25.296875 0.296875 30.59375 4.796875 \n",
"z\n",
"M 31 22.5 \n",
"L 30.59375 10.59375 \n",
"C 30.59375 9.296875 30 8.59375 29.203125 8 \n",
"C 26.40625 5.90625 23 4.09375 20 4.09375 \n",
"C 15.5 4.09375 12.59375 7.09375 12.59375 10.203125 \n",
"C 12.59375 14.703125 14.703125 18.09375 22.5 20.203125 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-97\"/>\n",
" <path d=\"M 9 23.5 \n",
"L 9 18 \n",
"C 9 10.5 8.796875 5.40625 8.09375 0 \n",
"L 8.296875 -0.296875 \n",
"C 9.5 -0.09375 11.796875 0 13 0 \n",
"C 14.203125 0 16.5 -0.09375 17.703125 -0.296875 \n",
"L 17.90625 0 \n",
"C 17.203125 5.703125 17 10.40625 17 18 \n",
"L 17 25.09375 \n",
"C 17 32.59375 17.296875 36.203125 17.90625 42.296875 \n",
"C 17.90625 43.203125 17.796875 43.296875 17 43.296875 \n",
"C 14.703125 43.09375 10.40625 43 8.296875 43.203125 \n",
"L 8.09375 42.90625 \n",
"C 8.703125 38.59375 9 31 9 23.5 \n",
"z\n",
"M 8 59.703125 \n",
"C 8 57 10.40625 54.59375 13.09375 54.59375 \n",
"C 15.796875 54.59375 18.203125 57 18.203125 59.703125 \n",
"C 18.203125 62.40625 15.796875 64.796875 13.09375 64.796875 \n",
"C 10.40625 64.796875 8 62.40625 8 59.703125 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-105\"/>\n",
" <path d=\"M 3.796875 20.5 \n",
"C 3.796875 8.5 11.703125 -1 25 -1 \n",
"C 38.203125 -1 46.203125 8.296875 46.203125 21.40625 \n",
"C 46.203125 35 38.90625 43.90625 25.40625 43.90625 \n",
"C 12.296875 43.90625 3.796875 34.703125 3.796875 20.5 \n",
"z\n",
"M 24.703125 39.90625 \n",
"C 35.296875 39.90625 37.40625 31.703125 37.40625 19.59375 \n",
"C 37.40625 10.09375 32.59375 3 25.90625 3 \n",
"C 15.296875 3 12.59375 14.5 12.59375 22.203125 \n",
"C 12.59375 30.90625 15.296875 39.90625 24.703125 39.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-111\"/>\n",
" <path d=\"M 46 18 \n",
"C 46 21.203125 46.203125 24.90625 46.203125 28.09375 \n",
"C 46.203125 38.5 42.796875 43.90625 33.796875 43.90625 \n",
"C 30 43.90625 22.90625 42.40625 16.5 34.90625 \n",
"L 16.296875 35.203125 \n",
"L 16.296875 42.5 \n",
"C 16.296875 43.296875 16.203125 43.5 15.703125 43.5 \n",
"C 13.5 43.09375 9.90625 43 7.59375 43.203125 \n",
"L 7.40625 42.90625 \n",
"C 8.09375 38.59375 8.296875 31 8.296875 23.5 \n",
"L 8.296875 18 \n",
"C 8.296875 10.5 8.203125 5.40625 7.40625 0 \n",
"L 7.59375 -0.296875 \n",
"C 8.796875 -0.09375 11.09375 0 12.296875 0 \n",
"C 13.5 0 15.796875 -0.09375 17 -0.296875 \n",
"L 17.203125 0 \n",
"C 16.40625 5.703125 16.296875 10.40625 16.296875 18 \n",
"L 16.296875 29.703125 \n",
"C 21.40625 35.703125 27.203125 37.90625 30.796875 37.90625 \n",
"C 35.90625 37.90625 38 35.90625 38 27.796875 \n",
"L 38 18 \n",
"C 38 10.5 37.796875 5.40625 37.09375 0 \n",
"L 37.296875 -0.296875 \n",
"C 38.5 -0.09375 40.796875 0 42 0 \n",
"C 43.203125 0 45.5 -0.09375 46.703125 -0.296875 \n",
"L 46.90625 0 \n",
"C 46.09375 5.703125 46 10.40625 46 18 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-110\"/>\n",
" <path id=\"LibertinusSans-Regular-32\"/>\n",
" <path d=\"M 9.90625 42.90625 \n",
"C 7.703125 42.90625 5.40625 42.90625 4.09375 43.09375 \n",
"C 3.40625 41.5 2.90625 40.5 1.90625 39 \n",
"L 2.40625 38.296875 \n",
"C 4.203125 38.40625 7.5 38.5 9.796875 38.5 \n",
"L 9.90625 38.5 \n",
"L 9.90625 19.90625 \n",
"C 9.90625 12.40625 9.796875 5.40625 8.90625 0 \n",
"L 9.09375 -0.296875 \n",
"C 10.296875 -0.09375 12.703125 0 13.90625 0 \n",
"C 15.09375 0 17.5 -0.09375 18.703125 -0.296875 \n",
"L 18.90625 0 \n",
"C 18.09375 5.703125 17.90625 12.40625 17.90625 19.90625 \n",
"L 17.90625 38.5 \n",
"L 21.296875 38.5 \n",
"C 23.703125 38.5 27.203125 38.40625 28.5 38.296875 \n",
"C 28.796875 39.90625 29.09375 40.90625 29.703125 42.40625 \n",
"L 29.203125 43.09375 \n",
"C 27.5 43 24.5 42.90625 22.203125 42.90625 \n",
"L 17.90625 42.90625 \n",
"L 17.90625 43.796875 \n",
"C 17.90625 47.40625 17.40625 52.59375 17.40625 54.40625 \n",
"C 17.40625 59.90625 21 63.703125 26.703125 63.703125 \n",
"C 29.296875 63.703125 31.40625 62.203125 32.5 60.203125 \n",
"L 33.59375 60.296875 \n",
"C 34.296875 63 35.40625 66.40625 36.40625 68.5 \n",
"L 36.296875 68.796875 \n",
"C 35.5 69.296875 33.703125 69.796875 31.796875 69.796875 \n",
"C 25.5 69.796875 19.203125 66.90625 15.40625 62.09375 \n",
"C 11.59375 57.296875 9.90625 52.59375 9.90625 46.796875 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-102\"/>\n",
" <path d=\"M 36.09375 5.796875 \n",
"L 36.296875 5.796875 \n",
"L 36.796875 0 \n",
"C 36.796875 -0.203125 37.09375 -0.296875 37.703125 -0.296875 \n",
"C 39 -0.09375 39.703125 0 41.203125 0 \n",
"C 42.40625 0 44.296875 -0.09375 45.59375 -0.296875 \n",
"L 45.796875 0 \n",
"C 45 4.296875 44.09375 11.703125 44.09375 19.203125 \n",
"L 44.09375 50 \n",
"C 44.09375 57.40625 44.5 62.59375 45 68.796875 \n",
"C 45 69.5 44.703125 69.796875 44.09375 69.796875 \n",
"C 41.59375 68.796875 39.5 68.09375 35.40625 67.796875 \n",
"L 35.203125 67.5 \n",
"C 36 63.203125 36.09375 55.796875 36.09375 48.203125 \n",
"L 36.09375 41.703125 \n",
"C 33.796875 43 29.703125 43.90625 27.703125 43.90625 \n",
"C 14.703125 43.90625 5.09375 34.90625 5.09375 21.296875 \n",
"C 5.09375 9 12.40625 -1 23.203125 -1 \n",
"C 28 -1 32.5 1.203125 36.09375 5.796875 \n",
"z\n",
"M 36.09375 11.296875 \n",
"C 32.5 6.703125 27.90625 4.203125 23.796875 4.203125 \n",
"C 18.40625 4.203125 13.796875 9.59375 13.796875 22.09375 \n",
"C 13.796875 37.09375 21.796875 39.90625 26.59375 39.90625 \n",
"C 31.296875 39.90625 33.703125 37.90625 36.09375 34.09375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-100\"/>\n",
" <path d=\"M 16.703125 33.40625 \n",
"L 16.703125 42.5 \n",
"C 16.703125 43.296875 16.59375 43.5 16.09375 43.5 \n",
"C 13.90625 43.09375 10.296875 43 8 43.203125 \n",
"L 7.796875 42.90625 \n",
"C 8.5 38.59375 8.703125 31 8.703125 23.5 \n",
"L 8.703125 18 \n",
"C 8.703125 10.5 8.59375 5.40625 7.796875 0 \n",
"L 8 -0.296875 \n",
"C 9.203125 -0.09375 11.5 0 12.703125 0 \n",
"C 13.90625 0 16.203125 -0.09375 17.40625 -0.296875 \n",
"L 17.59375 0 \n",
"C 16.90625 5.703125 16.703125 10.40625 16.703125 18 \n",
"L 16.703125 23.203125 \n",
"C 16.703125 27.40625 18 29.796875 20.09375 33.09375 \n",
"C 21.59375 35.296875 23.796875 36.59375 25.703125 36.59375 \n",
"C 27.703125 36.59375 29.59375 36.40625 30.90625 35.203125 \n",
"L 31.703125 35.40625 \n",
"L 33.703125 42.796875 \n",
"L 33.296875 43.203125 \n",
"C 31.59375 43.703125 31.5 43.90625 29.703125 43.90625 \n",
"C 24.296875 43.90625 21.40625 40.796875 17 33.203125 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-114\"/>\n",
" <path d=\"M 9 20 \n",
"C 9 12.59375 8.90625 5.40625 8.09375 0 \n",
"L 8.296875 -0.296875 \n",
"C 9.5 -0.09375 11.796875 0 13 0 \n",
"C 14.203125 0 16.5 -0.09375 17.703125 -0.296875 \n",
"L 17.90625 0 \n",
"C 17.09375 5.703125 17 12.5 17 20 \n",
"L 17 50 \n",
"C 17 57.5 17.40625 62.5 17.90625 68.796875 \n",
"C 17.90625 69.5 17.59375 69.796875 17 69.796875 \n",
"C 14.5 68.796875 12.40625 68.09375 8.296875 67.796875 \n",
"L 8.09375 67.5 \n",
"C 8.90625 63.203125 9 55.796875 9 48.203125 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-108\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-69\"/>\n",
" <use x=\"53.799988\" xlink:href=\"#LibertinusSans-Regular-120\"/>\n",
" <use x=\"99.299973\" xlink:href=\"#LibertinusSans-Regular-112\"/>\n",
" <use x=\"151.59996\" xlink:href=\"#LibertinusSans-Regular-101\"/>\n",
" <use x=\"196.899948\" xlink:href=\"#LibertinusSans-Regular-99\"/>\n",
" <use x=\"239.799942\" xlink:href=\"#LibertinusSans-Regular-116\"/>\n",
" <use x=\"273.799927\" xlink:href=\"#LibertinusSans-Regular-97\"/>\n",
" <use x=\"321.899918\" xlink:href=\"#LibertinusSans-Regular-116\"/>\n",
" <use x=\"355.899902\" xlink:href=\"#LibertinusSans-Regular-105\"/>\n",
" <use x=\"381.899887\" xlink:href=\"#LibertinusSans-Regular-111\"/>\n",
" <use x=\"431.899872\" xlink:href=\"#LibertinusSans-Regular-110\"/>\n",
" <use x=\"485.799866\" xlink:href=\"#LibertinusSans-Regular-32\"/>\n",
" <use x=\"510.79985\" xlink:href=\"#LibertinusSans-Regular-111\"/>\n",
" <use x=\"560.799835\" xlink:href=\"#LibertinusSans-Regular-102\"/>\n",
" <use x=\"592.199829\" xlink:href=\"#LibertinusSans-Regular-32\"/>\n",
" <use x=\"617.199814\" xlink:href=\"#LibertinusSans-Regular-97\"/>\n",
" <use x=\"665.299805\" xlink:href=\"#LibertinusSans-Regular-32\"/>\n",
" <use x=\"690.299789\" xlink:href=\"#LibertinusSans-Regular-100\"/>\n",
" <use x=\"743.299774\" xlink:href=\"#LibertinusSans-Regular-105\"/>\n",
" <use x=\"769.299759\" xlink:href=\"#LibertinusSans-Regular-99\"/>\n",
" <use x=\"812.199753\" xlink:href=\"#LibertinusSans-Regular-101\"/>\n",
" <use x=\"857.499741\" xlink:href=\"#LibertinusSans-Regular-32\"/>\n",
" <use x=\"882.499725\" xlink:href=\"#LibertinusSans-Regular-114\"/>\n",
" <use x=\"917.99971\" xlink:href=\"#LibertinusSans-Regular-111\"/>\n",
" <use x=\"967.999695\" xlink:href=\"#LibertinusSans-Regular-108\"/>\n",
" <use x=\"993.199692\" xlink:href=\"#LibertinusSans-Regular-108\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <defs>\n",
" <clipPath id=\"p342541b8ee\">\n",
" <rect height=\"217.44\" width=\"334.8\" x=\"18.14\" y=\"23.25075\"/>\n",
" </clipPath>\n",
" </defs>\n",
"</svg>\n"
],
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"N = 1000\n",
"roll = numpy.zeros(N, dtype=int)\n",
"expectation = numpy.zeros(N)\n",
"for i in range(N):\n",
" roll[i] = numpy.random.randint(1, 7)\n",
"for i in range(1, N):\n",
" expectation[i] = numpy.mean(roll[0:i])\n",
"plt.plot(expectation)\n",
"plt.title(\"Expectation of a dice roll\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The sympy.stats module has functionality that allows us to evaluate the expected value analytically. "
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{7}{2}$"
],
"text/plain": [
"7/2"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"D = sympy.stats.Die(\"D\", 6)\n",
"sympy.stats.E(D)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Simulating dice throws"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dice = scipy.stats.randint(1, 7)\n",
"dice.rvs(1000).max()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We simulated a thousand dice throws, and never rolled anything bigger than a 6 (that’s reassuring!)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What is the probability of a die rolling 4?"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.16666666666666666$"
],
"text/plain": [
"0.16666666666666666"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dice.pmf(4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What is the probability of rolling 4 or below?"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.6666666666666666$"
],
"text/plain": [
"0.6666666666666666"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dice.cdf(4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What is the probability of rolling between 2 and 4 (inclusive)?"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.5$"
],
"text/plain": [
"0.5"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dice.cdf(4) - dice.cdf(1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Again, using `sympy.stats` to calculate this analytically:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The probability of a dice roll of 4:"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{1}{6}$"
],
"text/plain": [
"1/6"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sympy.stats.P(sympy.Eq(D, 4))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Probability of rolling 4 or below:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{2}{3}$"
],
"text/plain": [
"2/3"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sympy.stats.P(D <= 4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Probability of rolling between 2 and 4 (inclusive):"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{1}{2}$"
],
"text/plain": [
"1/2"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sympy.stats.P(sympy.And(D >= 2, D <= 4))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now let’s look at what happens when we roll **three dice**. We’ll estimate the expected value and the probability mass function for the sum of three dice. "
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 10.5018$"
],
"text/plain": [
"10.5018"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"N = 10_000\n",
"roll = numpy.zeros(N, dtype=int)\n",
"for i in range(N):\n",
" roll[i] = scipy.stats.randint(1, 7).rvs(3).sum()\n",
"roll.mean()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can plot the probability mass function for the sum of three dice:"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
"<svg height=\"250.2675pt\" version=\"1.1\" viewBox=\"0 0 382.46 250.2675\" width=\"382.46pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
" <metadata>\n",
" <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
" <cc:Work>\n",
" <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
" <dc:date>2020-10-02T13:10:27.085909</dc:date>\n",
" <dc:format>image/svg+xml</dc:format>\n",
" <dc:creator>\n",
" <cc:Agent>\n",
" <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n",
" </cc:Agent>\n",
" </dc:creator>\n",
" </cc:Work>\n",
" </rdf:RDF>\n",
" </metadata>\n",
" <defs>\n",
" <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
" </defs>\n",
" <g id=\"figure_1\">\n",
" <g id=\"patch_1\">\n",
" <path d=\"M 0 250.2675 \n",
"L 382.46 250.2675 \n",
"L 382.46 0 \n",
"L 0 0 \n",
"z\n",
"\" style=\"fill:none;\"/>\n",
" </g>\n",
" <g id=\"axes_1\">\n",
" <g id=\"patch_2\">\n",
" <path d=\"M 40.46 224.64 \n",
"L 375.26 224.64 \n",
"L 375.26 7.2 \n",
"L 40.46 7.2 \n",
"z\n",
"\" style=\"fill:#eeeeee;\"/>\n",
" </g>\n",
" <g id=\"matplotlib.axis_1\">\n",
" <g id=\"xtick_1\">\n",
" <g id=\"line2d_1\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 96.26 224.64 \n",
"L 96.26 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_2\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 0 -3.5 \n",
"\" id=\"ma69a00553f\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"96.26\" xlink:href=\"#ma69a00553f\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_1\">\n",
" <!-- 5 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(92.54 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 20.203125 -1 \n",
"C 32.09375 -1 40.59375 7.796875 40.59375 19.59375 \n",
"C 40.59375 29.296875 34.09375 38 22.90625 38 \n",
"C 18.796875 38 14.203125 37.296875 12 36.5 \n",
"L 14.09375 54.203125 \n",
"C 17.796875 53.703125 22.09375 53.296875 26.796875 53.296875 \n",
"C 29.796875 53.296875 33.203125 53.40625 37.296875 53.90625 \n",
"L 38.90625 60.703125 \n",
"L 38.203125 61 \n",
"C 32.5 60.296875 27.09375 60 21.796875 60 \n",
"C 18.09375 60 13.796875 60.296875 10.40625 60.59375 \n",
"L 7.203125 31.203125 \n",
"L 7.90625 30.90625 \n",
"C 11.90625 32.5 15.59375 34 20.296875 34 \n",
"C 26.796875 34 31.796875 28.796875 31.796875 17.90625 \n",
"C 31.796875 8.703125 27.203125 3 20.40625 3 \n",
"C 12.90625 3 11.59375 7 8.296875 13 \n",
"L 6.90625 12.90625 \n",
"L 4.703125 4.90625 \n",
"L 5.09375 4.59375 \n",
"C 7.59375 2.40625 12.59375 -1 20.203125 -1 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-53\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_2\">\n",
" <g id=\"line2d_3\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 197.714545 224.64 \n",
"L 197.714545 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_4\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"197.714545\" xlink:href=\"#ma69a00553f\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_2\">\n",
" <!-- 10 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(190.274545 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 28.59375 18.90625 \n",
"L 28.59375 44.296875 \n",
"C 28.59375 55.09375 29.203125 59.09375 29.40625 60.5 \n",
"C 29.40625 61 29.09375 61 28.703125 61 \n",
"C 22.203125 58.90625 14.59375 55 6.796875 52.59375 \n",
"L 7.40625 49.703125 \n",
"C 11.90625 50.203125 16.796875 51.296875 18.796875 51.296875 \n",
"C 20.59375 51.296875 20.59375 47.296875 20.59375 43.703125 \n",
"L 20.59375 18.90625 \n",
"C 20.59375 11.09375 20.5 5.703125 19.796875 0 \n",
"L 19.90625 -0.296875 \n",
"C 19.90625 -0.296875 22.703125 0 24.5 0 \n",
"C 26.5 0 29.296875 -0.296875 29.296875 -0.296875 \n",
"L 29.5 0 \n",
"C 28.796875 6 28.59375 11 28.59375 18.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-49\"/>\n",
" <path d=\"M 22.796875 -1 \n",
"C 30.5 -1 42.09375 7.5 42.09375 30.90625 \n",
"C 42.09375 46.5 36.40625 54.203125 32.796875 57.5 \n",
"C 30.09375 60 26.90625 61 23.296875 61 \n",
"C 13.296875 61 3.90625 48.59375 3.90625 28.90625 \n",
"C 3.90625 12.703125 10.40625 -1 22.796875 -1 \n",
"z\n",
"M 23.296875 57.09375 \n",
"C 25 57.09375 26.59375 56.5 27.703125 55.5 \n",
"C 30.796875 52.90625 33.5 45.09375 33.5 31.703125 \n",
"C 33.5 22.5 33.203125 17.296875 31.796875 12.203125 \n",
"C 29.59375 3.90625 24.703125 2.90625 22.90625 2.90625 \n",
"C 13.59375 2.90625 12.5 20 12.5 28.703125 \n",
"C 12.5 53.40625 18.703125 57.09375 23.296875 57.09375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-48\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_3\">\n",
" <g id=\"line2d_5\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 299.169091 224.64 \n",
"L 299.169091 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_6\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"299.169091\" xlink:href=\"#ma69a00553f\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_3\">\n",
" <!-- 15 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(291.729091 239.3075)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"matplotlib.axis_2\">\n",
" <g id=\"ytick_1\">\n",
" <g id=\"line2d_7\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 40.46 214.756364 \n",
"L 375.26 214.756364 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_8\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 3.5 0 \n",
"\" id=\"ma03e88b6b0\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"40.46\" xlink:href=\"#ma03e88b6b0\" y=\"214.756364\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_4\">\n",
" <!-- 0 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(29.52 220.340114)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_2\">\n",
" <g id=\"line2d_9\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 40.46 175.905592 \n",
"L 375.26 175.905592 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_10\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"40.46\" xlink:href=\"#ma03e88b6b0\" y=\"175.905592\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_5\">\n",
" <!-- 250 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(14.64 181.489342)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 22.203125 55.296875 \n",
"C 27.40625 55.296875 32.796875 50.5 32.796875 43.5 \n",
"C 32.796875 39.296875 31.59375 34 29 30.09375 \n",
"C 21.796875 19.40625 10.40625 9.40625 5.40625 4.703125 \n",
"C 5.296875 4.296875 5.296875 3.90625 5.296875 3.40625 \n",
"C 5.296875 1.90625 5.796875 0.40625 6.296875 -0.5 \n",
"C 13.703125 -0.296875 17.90625 0 25.203125 0 \n",
"C 32.40625 0 35.40625 -0.203125 42.59375 -0.5 \n",
"C 42.40625 0.5 42.296875 1.703125 42.296875 2.796875 \n",
"C 42.296875 4.40625 42.40625 6 42.796875 7.5 \n",
"C 37.09375 7 34.09375 6.703125 24.5 6.703125 \n",
"C 21 6.703125 19 6.703125 16.296875 6.5 \n",
"C 16.203125 6.703125 16.203125 6.796875 16.203125 7 \n",
"C 16.203125 7.90625 17.203125 9 17.90625 9.703125 \n",
"C 22.796875 14.40625 27.5 18.90625 34.09375 27.796875 \n",
"C 37.796875 32.796875 41.40625 39.203125 41.40625 44.90625 \n",
"C 41.40625 54.40625 35 61 23.796875 61 \n",
"C 14.703125 61 8.90625 55.90625 6.59375 52.90625 \n",
"L 8.796875 46 \n",
"L 10.09375 45.90625 \n",
"C 11.5 48.90625 12 51 14.5 53 \n",
"C 16.5 54.59375 19.40625 55.296875 22.203125 55.296875 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-50\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_3\">\n",
" <g id=\"line2d_11\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 40.46 137.05482 \n",
"L 375.26 137.05482 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_12\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"40.46\" xlink:href=\"#ma03e88b6b0\" y=\"137.05482\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_6\">\n",
" <!-- 500 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(14.64 142.63857)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_4\">\n",
" <g id=\"line2d_13\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 40.46 98.204048 \n",
"L 375.26 98.204048 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_14\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"40.46\" xlink:href=\"#ma03e88b6b0\" y=\"98.204048\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_7\">\n",
" <!-- 750 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(14.64 103.787798)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 34.5 52.5 \n",
"C 26.703125 33.203125 19.09375 14.296875 12.40625 -0.703125 \n",
"L 12.703125 -1.296875 \n",
"L 20 -0.90625 \n",
"C 25.703125 16.09375 31.203125 32.703125 42.40625 60 \n",
"L 40.703125 61 \n",
"C 39.203125 60.5 37.40625 60 34.296875 60 \n",
"C 19.40625 60 10.59375 60.09375 6.296875 60.703125 \n",
"C 6.5 59.203125 6.796875 58 6.796875 56.5 \n",
"C 6.796875 55 6.5 53.09375 6.296875 51.59375 \n",
"C 13.59375 52.703125 28 52.703125 34.5 52.5 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-55\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-55\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_5\">\n",
" <g id=\"line2d_15\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 40.46 59.353276 \n",
"L 375.26 59.353276 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_16\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"40.46\" xlink:href=\"#ma03e88b6b0\" y=\"59.353276\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_8\">\n",
" <!-- 1000 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 64.937026)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"139.499954\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_6\">\n",
" <g id=\"line2d_17\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 40.46 20.502504 \n",
"L 375.26 20.502504 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_18\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"40.46\" xlink:href=\"#ma03e88b6b0\" y=\"20.502504\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_9\">\n",
" <!-- 1250 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 26.086254)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"92.999969\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" <use x=\"139.499954\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"LineCollection_1\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 55.678182 214.756364 \n",
"L 55.678182 208.074031 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 75.969091 214.756364 \n",
"L 75.969091 192.222916 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 96.26 214.756364 \n",
"L 96.26 171.398902 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 116.550909 214.756364 \n",
"L 116.550909 140.784494 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 136.841818 214.756364 \n",
"L 136.841818 103.798559 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 157.132727 214.756364 \n",
"L 157.132727 64.481578 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 177.423636 214.756364 \n",
"L 177.423636 43.812967 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 197.714545 214.756364 \n",
"L 197.714545 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 218.005455 214.756364 \n",
"L 218.005455 24.853791 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 238.296364 214.756364 \n",
"L 238.296364 35.576604 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 258.587273 214.756364 \n",
"L 258.587273 61.06271 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 278.878182 214.756364 \n",
"L 278.878182 105.197187 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 299.169091 214.756364 \n",
"L 299.169091 140.939897 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 319.46 214.756364 \n",
"L 319.46 169.378662 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 339.750909 214.756364 \n",
"L 339.750909 195.797187 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 360.041818 214.756364 \n",
"L 360.041818 207.607822 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"line2d_19\">\n",
" <defs>\n",
" <path d=\"M 0 3 \n",
"C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
"C 2.683901 1.55874 3 0.795609 3 0 \n",
"C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
"C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
"C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
"C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
"C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
"C -1.55874 2.683901 -0.795609 3 0 3 \n",
"z\n",
"\" id=\"m6a4297910c\" style=\"stroke:#348abd;\"/>\n",
" </defs>\n",
" <g clip-path=\"url(#p35f4aed2d0)\">\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"55.678182\" xlink:href=\"#m6a4297910c\" y=\"208.074031\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"75.969091\" xlink:href=\"#m6a4297910c\" y=\"192.222916\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"96.26\" xlink:href=\"#m6a4297910c\" y=\"171.398902\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"116.550909\" xlink:href=\"#m6a4297910c\" y=\"140.784494\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"136.841818\" xlink:href=\"#m6a4297910c\" y=\"103.798559\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"157.132727\" xlink:href=\"#m6a4297910c\" y=\"64.481578\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"177.423636\" xlink:href=\"#m6a4297910c\" y=\"43.812967\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"197.714545\" xlink:href=\"#m6a4297910c\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"218.005455\" xlink:href=\"#m6a4297910c\" y=\"24.853791\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"238.296364\" xlink:href=\"#m6a4297910c\" y=\"35.576604\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"258.587273\" xlink:href=\"#m6a4297910c\" y=\"61.06271\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"278.878182\" xlink:href=\"#m6a4297910c\" y=\"105.197187\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"299.169091\" xlink:href=\"#m6a4297910c\" y=\"140.939897\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"319.46\" xlink:href=\"#m6a4297910c\" y=\"169.378662\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"339.750909\" xlink:href=\"#m6a4297910c\" y=\"195.797187\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"360.041818\" xlink:href=\"#m6a4297910c\" y=\"207.607822\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"line2d_20\">\n",
" <path clip-path=\"url(#p35f4aed2d0)\" d=\"M 55.678182 214.756364 \n",
"L 360.041818 214.756364 \n",
"\" style=\"fill:none;stroke:#467821;stroke-linecap:square;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"patch_3\">\n",
" <path d=\"M 40.46 224.64 \n",
"L 40.46 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_4\">\n",
" <path d=\"M 375.26 224.64 \n",
"L 375.26 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_5\">\n",
" <path d=\"M 40.46 224.64 \n",
"L 375.26 224.64 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_6\">\n",
" <path d=\"M 40.46 7.2 \n",
"L 375.26 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <defs>\n",
" <clipPath id=\"p35f4aed2d0\">\n",
" <rect height=\"217.44\" width=\"334.8\" x=\"40.46\" y=\"7.2\"/>\n",
" </clipPath>\n",
" </defs>\n",
"</svg>\n"
],
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"values, counts = numpy.unique(roll, return_counts=True)\n",
"plt.stem(values, counts, use_line_collection=True)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The SymPy library allows us to calculate the expectation and probability distribution **analytically**. "
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{21}{2}$"
],
"text/plain": [
"21/2"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"D1 = sympy.stats.Die(\"D1\", 6)\n",
"D2 = sympy.stats.Die(\"D2\", 6)\n",
"D3 = sympy.stats.Die(\"D3\", 6)\n",
"Z = D1 + D2 + D3\n",
"sympy.stats.E(Z)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
"<svg height=\"250.2675pt\" version=\"1.1\" viewBox=\"0 0 385.98 250.2675\" width=\"385.98pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
" <metadata>\n",
" <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
" <cc:Work>\n",
" <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
" <dc:date>2020-10-02T13:10:27.240711</dc:date>\n",
" <dc:format>image/svg+xml</dc:format>\n",
" <dc:creator>\n",
" <cc:Agent>\n",
" <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n",
" </cc:Agent>\n",
" </dc:creator>\n",
" </cc:Work>\n",
" </rdf:RDF>\n",
" </metadata>\n",
" <defs>\n",
" <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
" </defs>\n",
" <g id=\"figure_1\">\n",
" <g id=\"patch_1\">\n",
" <path d=\"M 0 250.2675 \n",
"L 385.98 250.2675 \n",
"L 385.98 0 \n",
"L 0 0 \n",
"z\n",
"\" style=\"fill:none;\"/>\n",
" </g>\n",
" <g id=\"axes_1\">\n",
" <g id=\"patch_2\">\n",
" <path d=\"M 43.98 224.64 \n",
"L 378.78 224.64 \n",
"L 378.78 7.2 \n",
"L 43.98 7.2 \n",
"z\n",
"\" style=\"fill:#eeeeee;\"/>\n",
" </g>\n",
" <g id=\"matplotlib.axis_1\">\n",
" <g id=\"xtick_1\">\n",
" <g id=\"line2d_1\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 99.78 224.64 \n",
"L 99.78 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_2\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 0 -3.5 \n",
"\" id=\"maaf8edceac\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"99.78\" xlink:href=\"#maaf8edceac\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_1\">\n",
" <!-- 5 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(96.06 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 20.203125 -1 \n",
"C 32.09375 -1 40.59375 7.796875 40.59375 19.59375 \n",
"C 40.59375 29.296875 34.09375 38 22.90625 38 \n",
"C 18.796875 38 14.203125 37.296875 12 36.5 \n",
"L 14.09375 54.203125 \n",
"C 17.796875 53.703125 22.09375 53.296875 26.796875 53.296875 \n",
"C 29.796875 53.296875 33.203125 53.40625 37.296875 53.90625 \n",
"L 38.90625 60.703125 \n",
"L 38.203125 61 \n",
"C 32.5 60.296875 27.09375 60 21.796875 60 \n",
"C 18.09375 60 13.796875 60.296875 10.40625 60.59375 \n",
"L 7.203125 31.203125 \n",
"L 7.90625 30.90625 \n",
"C 11.90625 32.5 15.59375 34 20.296875 34 \n",
"C 26.796875 34 31.796875 28.796875 31.796875 17.90625 \n",
"C 31.796875 8.703125 27.203125 3 20.40625 3 \n",
"C 12.90625 3 11.59375 7 8.296875 13 \n",
"L 6.90625 12.90625 \n",
"L 4.703125 4.90625 \n",
"L 5.09375 4.59375 \n",
"C 7.59375 2.40625 12.59375 -1 20.203125 -1 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-53\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_2\">\n",
" <g id=\"line2d_3\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 201.234545 224.64 \n",
"L 201.234545 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_4\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"201.234545\" xlink:href=\"#maaf8edceac\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_2\">\n",
" <!-- 10 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(193.794545 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 28.59375 18.90625 \n",
"L 28.59375 44.296875 \n",
"C 28.59375 55.09375 29.203125 59.09375 29.40625 60.5 \n",
"C 29.40625 61 29.09375 61 28.703125 61 \n",
"C 22.203125 58.90625 14.59375 55 6.796875 52.59375 \n",
"L 7.40625 49.703125 \n",
"C 11.90625 50.203125 16.796875 51.296875 18.796875 51.296875 \n",
"C 20.59375 51.296875 20.59375 47.296875 20.59375 43.703125 \n",
"L 20.59375 18.90625 \n",
"C 20.59375 11.09375 20.5 5.703125 19.796875 0 \n",
"L 19.90625 -0.296875 \n",
"C 19.90625 -0.296875 22.703125 0 24.5 0 \n",
"C 26.5 0 29.296875 -0.296875 29.296875 -0.296875 \n",
"L 29.5 0 \n",
"C 28.796875 6 28.59375 11 28.59375 18.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-49\"/>\n",
" <path d=\"M 22.796875 -1 \n",
"C 30.5 -1 42.09375 7.5 42.09375 30.90625 \n",
"C 42.09375 46.5 36.40625 54.203125 32.796875 57.5 \n",
"C 30.09375 60 26.90625 61 23.296875 61 \n",
"C 13.296875 61 3.90625 48.59375 3.90625 28.90625 \n",
"C 3.90625 12.703125 10.40625 -1 22.796875 -1 \n",
"z\n",
"M 23.296875 57.09375 \n",
"C 25 57.09375 26.59375 56.5 27.703125 55.5 \n",
"C 30.796875 52.90625 33.5 45.09375 33.5 31.703125 \n",
"C 33.5 22.5 33.203125 17.296875 31.796875 12.203125 \n",
"C 29.59375 3.90625 24.703125 2.90625 22.90625 2.90625 \n",
"C 13.59375 2.90625 12.5 20 12.5 28.703125 \n",
"C 12.5 53.40625 18.703125 57.09375 23.296875 57.09375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-48\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_3\">\n",
" <g id=\"line2d_5\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 302.689091 224.64 \n",
"L 302.689091 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_6\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"302.689091\" xlink:href=\"#maaf8edceac\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_3\">\n",
" <!-- 15 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(295.249091 239.3075)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"matplotlib.axis_2\">\n",
" <g id=\"ytick_1\">\n",
" <g id=\"line2d_7\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 43.98 214.756364 \n",
"L 378.78 214.756364 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_8\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 3.5 0 \n",
"\" id=\"m36a07fc9f7\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m36a07fc9f7\" y=\"214.756364\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_4\">\n",
" <!-- 0.000 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 220.340114)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 5.40625 4.59375 \n",
"C 5.40625 1.40625 7.90625 -1.09375 11 -1.09375 \n",
"C 14.09375 -1.09375 16.59375 1.40625 16.59375 4.59375 \n",
"C 16.59375 7.703125 14.09375 10.203125 11 10.203125 \n",
"C 7.90625 10.203125 5.40625 7.703125 5.40625 4.59375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-46\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_2\">\n",
" <g id=\"line2d_9\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 43.98 175.221818 \n",
"L 378.78 175.221818 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_10\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m36a07fc9f7\" y=\"175.221818\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_5\">\n",
" <!-- 0.025 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 180.805568)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 22.203125 55.296875 \n",
"C 27.40625 55.296875 32.796875 50.5 32.796875 43.5 \n",
"C 32.796875 39.296875 31.59375 34 29 30.09375 \n",
"C 21.796875 19.40625 10.40625 9.40625 5.40625 4.703125 \n",
"C 5.296875 4.296875 5.296875 3.90625 5.296875 3.40625 \n",
"C 5.296875 1.90625 5.796875 0.40625 6.296875 -0.5 \n",
"C 13.703125 -0.296875 17.90625 0 25.203125 0 \n",
"C 32.40625 0 35.40625 -0.203125 42.59375 -0.5 \n",
"C 42.40625 0.5 42.296875 1.703125 42.296875 2.796875 \n",
"C 42.296875 4.40625 42.40625 6 42.796875 7.5 \n",
"C 37.09375 7 34.09375 6.703125 24.5 6.703125 \n",
"C 21 6.703125 19 6.703125 16.296875 6.5 \n",
"C 16.203125 6.703125 16.203125 6.796875 16.203125 7 \n",
"C 16.203125 7.90625 17.203125 9 17.90625 9.703125 \n",
"C 22.796875 14.40625 27.5 18.90625 34.09375 27.796875 \n",
"C 37.796875 32.796875 41.40625 39.203125 41.40625 44.90625 \n",
"C 41.40625 54.40625 35 61 23.796875 61 \n",
"C 14.703125 61 8.90625 55.90625 6.59375 52.90625 \n",
"L 8.796875 46 \n",
"L 10.09375 45.90625 \n",
"C 11.5 48.90625 12 51 14.5 53 \n",
"C 16.5 54.59375 19.40625 55.296875 22.203125 55.296875 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-50\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_3\">\n",
" <g id=\"line2d_11\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 43.98 135.687273 \n",
"L 378.78 135.687273 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_12\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m36a07fc9f7\" y=\"135.687273\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_6\">\n",
" <!-- 0.050 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 141.271023)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_4\">\n",
" <g id=\"line2d_13\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 43.98 96.152727 \n",
"L 378.78 96.152727 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_14\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m36a07fc9f7\" y=\"96.152727\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_7\">\n",
" <!-- 0.075 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 101.736477)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 34.5 52.5 \n",
"C 26.703125 33.203125 19.09375 14.296875 12.40625 -0.703125 \n",
"L 12.703125 -1.296875 \n",
"L 20 -0.90625 \n",
"C 25.703125 16.09375 31.203125 32.703125 42.40625 60 \n",
"L 40.703125 61 \n",
"C 39.203125 60.5 37.40625 60 34.296875 60 \n",
"C 19.40625 60 10.59375 60.09375 6.296875 60.703125 \n",
"C 6.5 59.203125 6.796875 58 6.796875 56.5 \n",
"C 6.796875 55 6.5 53.09375 6.296875 51.59375 \n",
"C 13.59375 52.703125 28 52.703125 34.5 52.5 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-55\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-55\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_5\">\n",
" <g id=\"line2d_15\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 43.98 56.618182 \n",
"L 378.78 56.618182 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_16\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m36a07fc9f7\" y=\"56.618182\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_8\">\n",
" <!-- 0.100 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 62.201932)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_6\">\n",
" <g id=\"line2d_17\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 43.98 17.083636 \n",
"L 378.78 17.083636 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_18\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m36a07fc9f7\" y=\"17.083636\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_9\">\n",
" <!-- 0.125 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 22.667386)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"LineCollection_1\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 59.198182 214.756364 \n",
"L 59.198182 207.435152 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 79.489091 214.756364 \n",
"L 79.489091 192.792727 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 99.78 214.756364 \n",
"L 99.78 170.829091 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 120.070909 214.756364 \n",
"L 120.070909 141.544242 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 140.361818 214.756364 \n",
"L 140.361818 104.938182 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 160.652727 214.756364 \n",
"L 160.652727 61.010909 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 180.943636 214.756364 \n",
"L 180.943636 31.726061 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 201.234545 214.756364 \n",
"L 201.234545 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 221.525455 214.756364 \n",
"L 221.525455 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 241.816364 214.756364 \n",
"L 241.816364 31.726061 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 262.107273 214.756364 \n",
"L 262.107273 61.010909 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 282.398182 214.756364 \n",
"L 282.398182 104.938182 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 302.689091 214.756364 \n",
"L 302.689091 141.544242 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 322.98 214.756364 \n",
"L 322.98 170.829091 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 343.270909 214.756364 \n",
"L 343.270909 192.792727 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 363.561818 214.756364 \n",
"L 363.561818 207.435152 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"line2d_19\">\n",
" <defs>\n",
" <path d=\"M 0 3 \n",
"C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
"C 2.683901 1.55874 3 0.795609 3 0 \n",
"C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
"C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
"C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
"C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
"C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
"C -1.55874 2.683901 -0.795609 3 0 3 \n",
"z\n",
"\" id=\"m2e2230a225\" style=\"stroke:#348abd;\"/>\n",
" </defs>\n",
" <g clip-path=\"url(#p680d415bca)\">\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"59.198182\" xlink:href=\"#m2e2230a225\" y=\"207.435152\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"79.489091\" xlink:href=\"#m2e2230a225\" y=\"192.792727\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"99.78\" xlink:href=\"#m2e2230a225\" y=\"170.829091\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"120.070909\" xlink:href=\"#m2e2230a225\" y=\"141.544242\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"140.361818\" xlink:href=\"#m2e2230a225\" y=\"104.938182\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"160.652727\" xlink:href=\"#m2e2230a225\" y=\"61.010909\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"180.943636\" xlink:href=\"#m2e2230a225\" y=\"31.726061\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"201.234545\" xlink:href=\"#m2e2230a225\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"221.525455\" xlink:href=\"#m2e2230a225\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"241.816364\" xlink:href=\"#m2e2230a225\" y=\"31.726061\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"262.107273\" xlink:href=\"#m2e2230a225\" y=\"61.010909\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"282.398182\" xlink:href=\"#m2e2230a225\" y=\"104.938182\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"302.689091\" xlink:href=\"#m2e2230a225\" y=\"141.544242\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"322.98\" xlink:href=\"#m2e2230a225\" y=\"170.829091\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"343.270909\" xlink:href=\"#m2e2230a225\" y=\"192.792727\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"363.561818\" xlink:href=\"#m2e2230a225\" y=\"207.435152\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"line2d_20\">\n",
" <path clip-path=\"url(#p680d415bca)\" d=\"M 59.198182 214.756364 \n",
"L 363.561818 214.756364 \n",
"\" style=\"fill:none;stroke:#467821;stroke-linecap:square;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"patch_3\">\n",
" <path d=\"M 43.98 224.64 \n",
"L 43.98 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_4\">\n",
" <path d=\"M 378.78 224.64 \n",
"L 378.78 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_5\">\n",
" <path d=\"M 43.98 224.64 \n",
"L 378.78 224.64 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_6\">\n",
" <path d=\"M 43.98 7.2 \n",
"L 378.78 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <defs>\n",
" <clipPath id=\"p680d415bca\">\n",
" <rect height=\"217.44\" width=\"334.8\" x=\"43.98\" y=\"7.2\"/>\n",
" </clipPath>\n",
" </defs>\n",
"</svg>\n"
],
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"pmf = sympy.stats.density(Z)\n",
"keys = pmf.keys()\n",
"plt.stem(list(keys), [pmf[k] for k in keys], use_line_collection=True)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The SymPy library also allows us to calculate more complicated expressions, such as the probability that the sum of three dice is greater than 10, given that the first throw is bigger than 4. This is called a *conditional probability*."
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{7}{9}$"
],
"text/plain": [
"7/9"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sympy.stats.P(D1 + D2 + D3 > 10, D1 > 4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can estimate the same value using Python, using a stochastic simulation (or Monte Carlo) approach:"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.797$"
],
"text/plain": [
"0.797"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"N = 1000\n",
"count = 0\n",
"hits = 0\n",
"while count < N:\n",
" # the second argument to randint is an exclusive upper bound\n",
" roll = scipy.stats.randint(1, 7).rvs(3)\n",
" if roll[0] > 4:\n",
" count += 1\n",
" if roll.sum() > 10:\n",
" hits += 1\n",
"hits / float(count)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The last banana thought experiment"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the following [thought experiment in probability by Leonardo Barichello](https://ed.ted.com/lessons/the-last-banana-a-thought-experiment-in-probability-leonardo-barichello): Two people are stranded on an island with only one banana to eat. To decide who gets it, they agree to play a game. Each of them will roll a fair 6-sided dice. If the largest number rolled is a 1, 2, 3, or 4, then Player 1 gets the banana. If the largest number rolled is a 5 or 6, then Player 2 gets it. Which player has the better chance?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we are not entirely convinced by our intuition concerning the banana, we can simulate this situation a large number of times, using a stochastic simulation (or Monte Carlo) approach:"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.439$"
],
"text/plain": [
"0.439"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"N = 1000\n",
"player1 = 0\n",
"for i in range(N):\n",
" # the second argument to randint is an exclusive upper bound\n",
" roll1 = scipy.stats.randint(1, 7).rvs(1)\n",
" roll2 = scipy.stats.randint(1, 7).rvs(1)\n",
" if max(roll1, roll2) <= 4:\n",
" player1 += 1\n",
"player1 / float(N)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The situation is also easy to resolve analytically: Player 1 gets the banana when both the dice rolls are smaller than 5. The probability of a roll smaller than 5 is 4/6, the two dice rolls are independent events, so their combined probability is the product of their individual probabilities: Player 1 gets the banana with probability"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.4444444444444444$"
],
"text/plain": [
"0.4444444444444444"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"4/6 * 4/6"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The gambles of the Chevalier de Méré"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let’s analyze two problems which were discussed between Antoine Gombaud, chevalier de Méré, a passionate gambler, and the mathematician Blaise Pascal. This discussion was a little daring for the time, because it went against established doctrine of the Catholic church that people should not attempt to predict the future (an activity that was reserved for the deity). The discussion and collaboration of Pascal with another mathematician, Pierre de Fermat, helped in the development of probability theory.\n",
"\n",
"The **first problem**: *is it a good idea to gamble on the appearance of at least one 6 when a dice is thrown 4 times*?\n",
"\n",
"The probability of losing this gamble is easy to calculate analytically: each throw has 5 chances out of 6 of not seeing a 6, and the events are independent. So the probability of winning is"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.5177469135802468$"
],
"text/plain": [
"0.5177469135802468"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 - (5/6.0)**4"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The probability of winning is greater than 0.5. We can also check this problem with SymPy:"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.517746913580247$"
],
"text/plain": [
"0.517746913580247"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sympy.stats\n",
"\n",
"D1 = sympy.stats.Die(\"D1\", 6)\n",
"D2 = sympy.stats.Die(\"D2\", 6)\n",
"D3 = sympy.stats.Die(\"D3\", 6)\n",
"D4 = sympy.stats.Die(\"D4\", 6)\n",
"\n",
"sympy.stats.P(sympy.Or(D1 > 5, sympy.Or(D2 > 5, sympy.Or(D3 > 5, D4 > 5)))) + 0.0"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The **second problem**: *is it a good idea to gamble on the appearance of at least one double six when two dice are thrown 24 times*? \n",
"\n",
"The probability of losing this gamble is also easy to calculate: there are 35 chances out of 36 (6 * 6) of not seeing a double 6 on each double throw, so the probability of winning is"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.4914038761309034$"
],
"text/plain": [
"0.4914038761309034"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 - (35/36.0)**24"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So this is not a good gamble. We can also calculate this analytically with SymPy, by modelling a Binomial random variable:"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.491403876130903$"
],
"text/plain": [
"0.491403876130903"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A = sympy.stats.Die(\"A\", 6)\n",
"B = sympy.stats.Die(\"B\", 6)\n",
"doublesix = sympy.stats.Binomial(\"DoubleSix\", 24, sympy.stats.P(sympy.And(A > 5, B > 5)))\n",
"sympy.stats.P(doublesix >= 1) + 0.0"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"**Exercise**: write some Python code to simulate this gamble and check that you obtain a similar probability. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Pepys and Newton"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Samuel Pepys was a great diarist of the English language and a friend of Isaac Newton’s. Pepys was a gambler and [wrote to Newton](https://en.wikipedia.org/wiki/Newton%E2%80%93Pepys_problem) to ask which of three events is the most likely:\n",
"\n",
"1. at least one six comes up when six fair dice are rolled;\n",
"2. at least two sixes come up when 12 dice are rolled;\n",
"3. at least three sixes come up when 18 dice are rolled.\n",
"\n",
"Now Newton wasn’t able to use Python, and spent a while working out the answers, but we can [stand on the shoulders of giants](https://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants) and figure this out quite easily. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Possibility 1**: the probability of rolling at least one six is 1 minus the probability of zero sixes, which is"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.6651020233196159$"
],
"text/plain": [
"0.6651020233196159"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 - (5/6.0)**6"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Possibility 2**: the probability of at least two sixes is 1 minus the probability of zero sixes, minus the probability of a single six. The probability of zero sixes is easy to calculate; here are three ways of calculating it."
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.11215665478461515$"
],
"text/plain": [
"0.11215665478461515"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# throw a non-6 12 times\n",
"(5/6.0)**12"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.11215665478461512$"
],
"text/plain": [
"0.11215665478461512"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# probability mass at 0 of a binomial distribution with n=18, p=1/6\n",
"scipy.stats.binom(12, 1/6.0).pmf(0)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.112156654784615$"
],
"text/plain": [
"0.112156654784615"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# a symbolic representation of the same binomial distribution as above\n",
"D12 = sympy.stats.Binomial(\"18dice\", 12, 1/6)\n",
"sympy.stats.P(sympy.Eq(D12, 0))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The probability of rolling a single six can likewise be determined using the binomial distribution."
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.26917597148307565$"
],
"text/plain": [
"0.26917597148307565"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"scipy.stats.binom(12, 1/6.0).pmf(1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"so the final answer is"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.6186673737323092$"
],
"text/plain": [
"0.6186673737323092"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"roll12 = scipy.stats.binom(12, 1/6.0)\n",
"1 - roll12.pmf(0) - roll12.pmf(1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Possibility 3**: in the same way, the probability of at least three sixes when rolling 18 dice is one minus the probability of zero sixes, minus the probability of one six, minus the probability of two sixes."
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.597345685947724$"
],
"text/plain": [
"0.597345685947724"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"roll18 = scipy.stats.binom(18, 1/6.0)\n",
"1 - roll18.pmf(0) - roll18.pmf(1) - roll18.pmf(2)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle 0.5973456859477233$"
],
"text/plain": [
"0.5973456859477233"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 - roll18.cdf(2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Conclusion: it’s best to bet on possibility 1."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Dice throws in Dungeons and dragons"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Dungeons and dragons](https://en.wikipedia.org/wiki/Dungeons_%26_Dragons) is a well-known role-playing game, where dice throws are widely used to determine evolution of the game. For example, a dice throw might determine the level of damage generated by some game action. \n",
"\n",
"A [question you might ask yourself](https://boredzo.org/blog/archives/2020-01-25/probability-distribution-of-multiplied-dice-rolls) when playing: Is there any difference between rolling 1d8×2 (that is, rolling exactly one d8 and multiplying the result by 2) and rolling 2d8 (that is, rolling exactly two d8s and not modifying the result)?\n",
"\n",
"Intuitively, you might think these will result in similar probability distributions (if you think a little, the 1d8x2 is obviously not going to generate any odd values, unlike 2d8). Actually, they are very different! "
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
"<svg height=\"250.2675pt\" version=\"1.1\" viewBox=\"0 0 385.98 250.2675\" width=\"385.98pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
" <metadata>\n",
" <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
" <cc:Work>\n",
" <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
" <dc:date>2020-10-02T13:10:30.945607</dc:date>\n",
" <dc:format>image/svg+xml</dc:format>\n",
" <dc:creator>\n",
" <cc:Agent>\n",
" <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n",
" </cc:Agent>\n",
" </dc:creator>\n",
" </cc:Work>\n",
" </rdf:RDF>\n",
" </metadata>\n",
" <defs>\n",
" <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
" </defs>\n",
" <g id=\"figure_1\">\n",
" <g id=\"patch_1\">\n",
" <path d=\"M 0 250.2675 \n",
"L 385.98 250.2675 \n",
"L 385.98 0 \n",
"L 0 0 \n",
"z\n",
"\" style=\"fill:none;\"/>\n",
" </g>\n",
" <g id=\"axes_1\">\n",
" <g id=\"patch_2\">\n",
" <path d=\"M 43.98 224.64 \n",
"L 378.78 224.64 \n",
"L 378.78 7.2 \n",
"L 43.98 7.2 \n",
"z\n",
"\" style=\"fill:#eeeeee;\"/>\n",
" </g>\n",
" <g id=\"matplotlib.axis_1\">\n",
" <g id=\"xtick_1\">\n",
" <g id=\"line2d_1\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 124.418961 224.64 \n",
"L 124.418961 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_2\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 0 -3.5 \n",
"\" id=\"m79a76018eb\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"124.418961\" xlink:href=\"#m79a76018eb\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_1\">\n",
" <!-- 5 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(120.698961 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 20.203125 -1 \n",
"C 32.09375 -1 40.59375 7.796875 40.59375 19.59375 \n",
"C 40.59375 29.296875 34.09375 38 22.90625 38 \n",
"C 18.796875 38 14.203125 37.296875 12 36.5 \n",
"L 14.09375 54.203125 \n",
"C 17.796875 53.703125 22.09375 53.296875 26.796875 53.296875 \n",
"C 29.796875 53.296875 33.203125 53.40625 37.296875 53.90625 \n",
"L 38.90625 60.703125 \n",
"L 38.203125 61 \n",
"C 32.5 60.296875 27.09375 60 21.796875 60 \n",
"C 18.09375 60 13.796875 60.296875 10.40625 60.59375 \n",
"L 7.203125 31.203125 \n",
"L 7.90625 30.90625 \n",
"C 11.90625 32.5 15.59375 34 20.296875 34 \n",
"C 26.796875 34 31.796875 28.796875 31.796875 17.90625 \n",
"C 31.796875 8.703125 27.203125 3 20.40625 3 \n",
"C 12.90625 3 11.59375 7 8.296875 13 \n",
"L 6.90625 12.90625 \n",
"L 4.703125 4.90625 \n",
"L 5.09375 4.59375 \n",
"C 7.59375 2.40625 12.59375 -1 20.203125 -1 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-53\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_2\">\n",
" <g id=\"line2d_3\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 233.12026 224.64 \n",
"L 233.12026 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_4\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"233.12026\" xlink:href=\"#m79a76018eb\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_2\">\n",
" <!-- 10 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(225.68026 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 28.59375 18.90625 \n",
"L 28.59375 44.296875 \n",
"C 28.59375 55.09375 29.203125 59.09375 29.40625 60.5 \n",
"C 29.40625 61 29.09375 61 28.703125 61 \n",
"C 22.203125 58.90625 14.59375 55 6.796875 52.59375 \n",
"L 7.40625 49.703125 \n",
"C 11.90625 50.203125 16.796875 51.296875 18.796875 51.296875 \n",
"C 20.59375 51.296875 20.59375 47.296875 20.59375 43.703125 \n",
"L 20.59375 18.90625 \n",
"C 20.59375 11.09375 20.5 5.703125 19.796875 0 \n",
"L 19.90625 -0.296875 \n",
"C 19.90625 -0.296875 22.703125 0 24.5 0 \n",
"C 26.5 0 29.296875 -0.296875 29.296875 -0.296875 \n",
"L 29.5 0 \n",
"C 28.796875 6 28.59375 11 28.59375 18.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-49\"/>\n",
" <path d=\"M 22.796875 -1 \n",
"C 30.5 -1 42.09375 7.5 42.09375 30.90625 \n",
"C 42.09375 46.5 36.40625 54.203125 32.796875 57.5 \n",
"C 30.09375 60 26.90625 61 23.296875 61 \n",
"C 13.296875 61 3.90625 48.59375 3.90625 28.90625 \n",
"C 3.90625 12.703125 10.40625 -1 22.796875 -1 \n",
"z\n",
"M 23.296875 57.09375 \n",
"C 25 57.09375 26.59375 56.5 27.703125 55.5 \n",
"C 30.796875 52.90625 33.5 45.09375 33.5 31.703125 \n",
"C 33.5 22.5 33.203125 17.296875 31.796875 12.203125 \n",
"C 29.59375 3.90625 24.703125 2.90625 22.90625 2.90625 \n",
"C 13.59375 2.90625 12.5 20 12.5 28.703125 \n",
"C 12.5 53.40625 18.703125 57.09375 23.296875 57.09375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-48\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_3\">\n",
" <g id=\"line2d_5\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 341.821558 224.64 \n",
"L 341.821558 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_6\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"341.821558\" xlink:href=\"#m79a76018eb\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_3\">\n",
" <!-- 15 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(334.381558 239.3075)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"matplotlib.axis_2\">\n",
" <g id=\"ytick_1\">\n",
" <g id=\"line2d_7\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 43.98 214.756364 \n",
"L 378.78 214.756364 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_8\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 3.5 0 \n",
"\" id=\"m0871756542\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m0871756542\" y=\"214.756364\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_4\">\n",
" <!-- 0.000 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 220.340114)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 5.40625 4.59375 \n",
"C 5.40625 1.40625 7.90625 -1.09375 11 -1.09375 \n",
"C 14.09375 -1.09375 16.59375 1.40625 16.59375 4.59375 \n",
"C 16.59375 7.703125 14.09375 10.203125 11 10.203125 \n",
"C 7.90625 10.203125 5.40625 7.703125 5.40625 4.59375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-46\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_2\">\n",
" <g id=\"line2d_9\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 43.98 175.221818 \n",
"L 378.78 175.221818 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_10\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m0871756542\" y=\"175.221818\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_5\">\n",
" <!-- 0.025 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 180.805568)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 22.203125 55.296875 \n",
"C 27.40625 55.296875 32.796875 50.5 32.796875 43.5 \n",
"C 32.796875 39.296875 31.59375 34 29 30.09375 \n",
"C 21.796875 19.40625 10.40625 9.40625 5.40625 4.703125 \n",
"C 5.296875 4.296875 5.296875 3.90625 5.296875 3.40625 \n",
"C 5.296875 1.90625 5.796875 0.40625 6.296875 -0.5 \n",
"C 13.703125 -0.296875 17.90625 0 25.203125 0 \n",
"C 32.40625 0 35.40625 -0.203125 42.59375 -0.5 \n",
"C 42.40625 0.5 42.296875 1.703125 42.296875 2.796875 \n",
"C 42.296875 4.40625 42.40625 6 42.796875 7.5 \n",
"C 37.09375 7 34.09375 6.703125 24.5 6.703125 \n",
"C 21 6.703125 19 6.703125 16.296875 6.5 \n",
"C 16.203125 6.703125 16.203125 6.796875 16.203125 7 \n",
"C 16.203125 7.90625 17.203125 9 17.90625 9.703125 \n",
"C 22.796875 14.40625 27.5 18.90625 34.09375 27.796875 \n",
"C 37.796875 32.796875 41.40625 39.203125 41.40625 44.90625 \n",
"C 41.40625 54.40625 35 61 23.796875 61 \n",
"C 14.703125 61 8.90625 55.90625 6.59375 52.90625 \n",
"L 8.796875 46 \n",
"L 10.09375 45.90625 \n",
"C 11.5 48.90625 12 51 14.5 53 \n",
"C 16.5 54.59375 19.40625 55.296875 22.203125 55.296875 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-50\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_3\">\n",
" <g id=\"line2d_11\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 43.98 135.687273 \n",
"L 378.78 135.687273 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_12\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m0871756542\" y=\"135.687273\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_6\">\n",
" <!-- 0.050 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 141.271023)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_4\">\n",
" <g id=\"line2d_13\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 43.98 96.152727 \n",
"L 378.78 96.152727 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_14\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m0871756542\" y=\"96.152727\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_7\">\n",
" <!-- 0.075 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 101.736477)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 34.5 52.5 \n",
"C 26.703125 33.203125 19.09375 14.296875 12.40625 -0.703125 \n",
"L 12.703125 -1.296875 \n",
"L 20 -0.90625 \n",
"C 25.703125 16.09375 31.203125 32.703125 42.40625 60 \n",
"L 40.703125 61 \n",
"C 39.203125 60.5 37.40625 60 34.296875 60 \n",
"C 19.40625 60 10.59375 60.09375 6.296875 60.703125 \n",
"C 6.5 59.203125 6.796875 58 6.796875 56.5 \n",
"C 6.796875 55 6.5 53.09375 6.296875 51.59375 \n",
"C 13.59375 52.703125 28 52.703125 34.5 52.5 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-55\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-55\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_5\">\n",
" <g id=\"line2d_15\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 43.98 56.618182 \n",
"L 378.78 56.618182 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_16\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m0871756542\" y=\"56.618182\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_8\">\n",
" <!-- 0.100 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 62.201932)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_6\">\n",
" <g id=\"line2d_17\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 43.98 17.083636 \n",
"L 378.78 17.083636 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_18\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m0871756542\" y=\"17.083636\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_9\">\n",
" <!-- 0.125 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 22.667386)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"LineCollection_1\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 59.198182 214.756364 \n",
"L 59.198182 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 102.678701 214.756364 \n",
"L 102.678701 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 146.159221 214.756364 \n",
"L 146.159221 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 189.63974 214.756364 \n",
"L 189.63974 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 233.12026 214.756364 \n",
"L 233.12026 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 276.600779 214.756364 \n",
"L 276.600779 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 320.081299 214.756364 \n",
"L 320.081299 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 363.561818 214.756364 \n",
"L 363.561818 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"line2d_19\">\n",
" <defs>\n",
" <path d=\"M 0 3 \n",
"C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
"C 2.683901 1.55874 3 0.795609 3 0 \n",
"C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
"C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
"C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
"C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
"C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
"C -1.55874 2.683901 -0.795609 3 0 3 \n",
"z\n",
"\" id=\"m1af5f164b1\" style=\"stroke:#348abd;\"/>\n",
" </defs>\n",
" <g clip-path=\"url(#pc07cd274ff)\">\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"59.198182\" xlink:href=\"#m1af5f164b1\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"102.678701\" xlink:href=\"#m1af5f164b1\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"146.159221\" xlink:href=\"#m1af5f164b1\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"189.63974\" xlink:href=\"#m1af5f164b1\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"233.12026\" xlink:href=\"#m1af5f164b1\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"276.600779\" xlink:href=\"#m1af5f164b1\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"320.081299\" xlink:href=\"#m1af5f164b1\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"363.561818\" xlink:href=\"#m1af5f164b1\" y=\"17.083636\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"line2d_20\">\n",
" <path clip-path=\"url(#pc07cd274ff)\" d=\"M 59.198182 214.756364 \n",
"L 363.561818 214.756364 \n",
"\" style=\"fill:none;stroke:#467821;stroke-linecap:square;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"patch_3\">\n",
" <path d=\"M 43.98 224.64 \n",
"L 43.98 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_4\">\n",
" <path d=\"M 378.78 224.64 \n",
"L 378.78 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_5\">\n",
" <path d=\"M 43.98 224.64 \n",
"L 378.78 224.64 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_6\">\n",
" <path d=\"M 43.98 7.2 \n",
"L 378.78 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <defs>\n",
" <clipPath id=\"pc07cd274ff\">\n",
" <rect height=\"217.44\" width=\"334.8\" x=\"43.98\" y=\"7.2\"/>\n",
" </clipPath>\n",
" </defs>\n",
"</svg>\n"
],
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"# roll one dice and multiply by two\n",
"D8 = sympy.stats.Die(\"D8\", 8)\n",
"pmf = sympy.stats.density(D8 * 2)\n",
"keys = pmf.keys()\n",
"plt.stem(list(keys), [pmf[k] for k in keys], use_line_collection=True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
"<svg height=\"250.2675pt\" version=\"1.1\" viewBox=\"0 0 385.98 250.2675\" width=\"385.98pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
" <metadata>\n",
" <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
" <cc:Work>\n",
" <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
" <dc:date>2020-10-02T13:10:31.045991</dc:date>\n",
" <dc:format>image/svg+xml</dc:format>\n",
" <dc:creator>\n",
" <cc:Agent>\n",
" <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n",
" </cc:Agent>\n",
" </dc:creator>\n",
" </cc:Work>\n",
" </rdf:RDF>\n",
" </metadata>\n",
" <defs>\n",
" <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
" </defs>\n",
" <g id=\"figure_1\">\n",
" <g id=\"patch_1\">\n",
" <path d=\"M 0 250.2675 \n",
"L 385.98 250.2675 \n",
"L 385.98 0 \n",
"L 0 0 \n",
"z\n",
"\" style=\"fill:none;\"/>\n",
" </g>\n",
" <g id=\"axes_1\">\n",
" <g id=\"patch_2\">\n",
" <path d=\"M 43.98 224.64 \n",
"L 378.78 224.64 \n",
"L 378.78 7.2 \n",
"L 43.98 7.2 \n",
"z\n",
"\" style=\"fill:#eeeeee;\"/>\n",
" </g>\n",
" <g id=\"matplotlib.axis_1\">\n",
" <g id=\"xtick_1\">\n",
" <g id=\"line2d_1\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 124.418961 224.64 \n",
"L 124.418961 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_2\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 0 -3.5 \n",
"\" id=\"m4d4ad02f67\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"124.418961\" xlink:href=\"#m4d4ad02f67\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_1\">\n",
" <!-- 5 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(120.698961 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 20.203125 -1 \n",
"C 32.09375 -1 40.59375 7.796875 40.59375 19.59375 \n",
"C 40.59375 29.296875 34.09375 38 22.90625 38 \n",
"C 18.796875 38 14.203125 37.296875 12 36.5 \n",
"L 14.09375 54.203125 \n",
"C 17.796875 53.703125 22.09375 53.296875 26.796875 53.296875 \n",
"C 29.796875 53.296875 33.203125 53.40625 37.296875 53.90625 \n",
"L 38.90625 60.703125 \n",
"L 38.203125 61 \n",
"C 32.5 60.296875 27.09375 60 21.796875 60 \n",
"C 18.09375 60 13.796875 60.296875 10.40625 60.59375 \n",
"L 7.203125 31.203125 \n",
"L 7.90625 30.90625 \n",
"C 11.90625 32.5 15.59375 34 20.296875 34 \n",
"C 26.796875 34 31.796875 28.796875 31.796875 17.90625 \n",
"C 31.796875 8.703125 27.203125 3 20.40625 3 \n",
"C 12.90625 3 11.59375 7 8.296875 13 \n",
"L 6.90625 12.90625 \n",
"L 4.703125 4.90625 \n",
"L 5.09375 4.59375 \n",
"C 7.59375 2.40625 12.59375 -1 20.203125 -1 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-53\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_2\">\n",
" <g id=\"line2d_3\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 233.12026 224.64 \n",
"L 233.12026 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_4\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"233.12026\" xlink:href=\"#m4d4ad02f67\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_2\">\n",
" <!-- 10 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(225.68026 239.3075)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 28.59375 18.90625 \n",
"L 28.59375 44.296875 \n",
"C 28.59375 55.09375 29.203125 59.09375 29.40625 60.5 \n",
"C 29.40625 61 29.09375 61 28.703125 61 \n",
"C 22.203125 58.90625 14.59375 55 6.796875 52.59375 \n",
"L 7.40625 49.703125 \n",
"C 11.90625 50.203125 16.796875 51.296875 18.796875 51.296875 \n",
"C 20.59375 51.296875 20.59375 47.296875 20.59375 43.703125 \n",
"L 20.59375 18.90625 \n",
"C 20.59375 11.09375 20.5 5.703125 19.796875 0 \n",
"L 19.90625 -0.296875 \n",
"C 19.90625 -0.296875 22.703125 0 24.5 0 \n",
"C 26.5 0 29.296875 -0.296875 29.296875 -0.296875 \n",
"L 29.5 0 \n",
"C 28.796875 6 28.59375 11 28.59375 18.90625 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-49\"/>\n",
" <path d=\"M 22.796875 -1 \n",
"C 30.5 -1 42.09375 7.5 42.09375 30.90625 \n",
"C 42.09375 46.5 36.40625 54.203125 32.796875 57.5 \n",
"C 30.09375 60 26.90625 61 23.296875 61 \n",
"C 13.296875 61 3.90625 48.59375 3.90625 28.90625 \n",
"C 3.90625 12.703125 10.40625 -1 22.796875 -1 \n",
"z\n",
"M 23.296875 57.09375 \n",
"C 25 57.09375 26.59375 56.5 27.703125 55.5 \n",
"C 30.796875 52.90625 33.5 45.09375 33.5 31.703125 \n",
"C 33.5 22.5 33.203125 17.296875 31.796875 12.203125 \n",
"C 29.59375 3.90625 24.703125 2.90625 22.90625 2.90625 \n",
"C 13.59375 2.90625 12.5 20 12.5 28.703125 \n",
"C 12.5 53.40625 18.703125 57.09375 23.296875 57.09375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-48\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"xtick_3\">\n",
" <g id=\"line2d_5\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 341.821558 224.64 \n",
"L 341.821558 7.2 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_6\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"341.821558\" xlink:href=\"#m4d4ad02f67\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_3\">\n",
" <!-- 15 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(334.381558 239.3075)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"matplotlib.axis_2\">\n",
" <g id=\"ytick_1\">\n",
" <g id=\"line2d_7\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 43.98 214.756364 \n",
"L 378.78 214.756364 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_8\">\n",
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 3.5 0 \n",
"\" id=\"m2669b889f8\" style=\"stroke:#808080;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m2669b889f8\" y=\"214.756364\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_4\">\n",
" <!-- 0.000 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 220.340114)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 5.40625 4.59375 \n",
"C 5.40625 1.40625 7.90625 -1.09375 11 -1.09375 \n",
"C 14.09375 -1.09375 16.59375 1.40625 16.59375 4.59375 \n",
"C 16.59375 7.703125 14.09375 10.203125 11 10.203125 \n",
"C 7.90625 10.203125 5.40625 7.703125 5.40625 4.59375 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-46\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_2\">\n",
" <g id=\"line2d_9\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 43.98 175.221818 \n",
"L 378.78 175.221818 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_10\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m2669b889f8\" y=\"175.221818\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_5\">\n",
" <!-- 0.025 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 180.805568)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 22.203125 55.296875 \n",
"C 27.40625 55.296875 32.796875 50.5 32.796875 43.5 \n",
"C 32.796875 39.296875 31.59375 34 29 30.09375 \n",
"C 21.796875 19.40625 10.40625 9.40625 5.40625 4.703125 \n",
"C 5.296875 4.296875 5.296875 3.90625 5.296875 3.40625 \n",
"C 5.296875 1.90625 5.796875 0.40625 6.296875 -0.5 \n",
"C 13.703125 -0.296875 17.90625 0 25.203125 0 \n",
"C 32.40625 0 35.40625 -0.203125 42.59375 -0.5 \n",
"C 42.40625 0.5 42.296875 1.703125 42.296875 2.796875 \n",
"C 42.296875 4.40625 42.40625 6 42.796875 7.5 \n",
"C 37.09375 7 34.09375 6.703125 24.5 6.703125 \n",
"C 21 6.703125 19 6.703125 16.296875 6.5 \n",
"C 16.203125 6.703125 16.203125 6.796875 16.203125 7 \n",
"C 16.203125 7.90625 17.203125 9 17.90625 9.703125 \n",
"C 22.796875 14.40625 27.5 18.90625 34.09375 27.796875 \n",
"C 37.796875 32.796875 41.40625 39.203125 41.40625 44.90625 \n",
"C 41.40625 54.40625 35 61 23.796875 61 \n",
"C 14.703125 61 8.90625 55.90625 6.59375 52.90625 \n",
"L 8.796875 46 \n",
"L 10.09375 45.90625 \n",
"C 11.5 48.90625 12 51 14.5 53 \n",
"C 16.5 54.59375 19.40625 55.296875 22.203125 55.296875 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-50\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_3\">\n",
" <g id=\"line2d_11\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 43.98 135.687273 \n",
"L 378.78 135.687273 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_12\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m2669b889f8\" y=\"135.687273\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_6\">\n",
" <!-- 0.050 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 141.271023)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_4\">\n",
" <g id=\"line2d_13\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 43.98 96.152727 \n",
"L 378.78 96.152727 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_14\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m2669b889f8\" y=\"96.152727\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_7\">\n",
" <!-- 0.075 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 101.736477)scale(0.16 -0.16)\">\n",
" <defs>\n",
" <path d=\"M 34.5 52.5 \n",
"C 26.703125 33.203125 19.09375 14.296875 12.40625 -0.703125 \n",
"L 12.703125 -1.296875 \n",
"L 20 -0.90625 \n",
"C 25.703125 16.09375 31.203125 32.703125 42.40625 60 \n",
"L 40.703125 61 \n",
"C 39.203125 60.5 37.40625 60 34.296875 60 \n",
"C 19.40625 60 10.59375 60.09375 6.296875 60.703125 \n",
"C 6.5 59.203125 6.796875 58 6.796875 56.5 \n",
"C 6.796875 55 6.5 53.09375 6.296875 51.59375 \n",
"C 13.59375 52.703125 28 52.703125 34.5 52.5 \n",
"z\n",
"\" id=\"LibertinusSans-Regular-55\"/>\n",
" </defs>\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-55\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_5\">\n",
" <g id=\"line2d_15\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 43.98 56.618182 \n",
"L 378.78 56.618182 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_16\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m2669b889f8\" y=\"56.618182\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_8\">\n",
" <!-- 0.100 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 62.201932)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"ytick_6\">\n",
" <g id=\"line2d_17\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 43.98 17.083636 \n",
"L 378.78 17.083636 \n",
"\" style=\"fill:none;stroke:#b2b2b2;stroke-dasharray:1.85,0.8;stroke-dashoffset:0;stroke-width:0.5;\"/>\n",
" </g>\n",
" <g id=\"line2d_18\">\n",
" <g>\n",
" <use style=\"fill:#808080;stroke:#808080;stroke-width:0.8;\" x=\"43.98\" xlink:href=\"#m2669b889f8\" y=\"17.083636\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_9\">\n",
" <!-- 0.125 -->\n",
" <g style=\"fill:#808080;\" transform=\"translate(7.2 22.667386)scale(0.16 -0.16)\">\n",
" <use xlink:href=\"#LibertinusSans-Regular-48\"/>\n",
" <use x=\"46.499985\" xlink:href=\"#LibertinusSans-Regular-46\"/>\n",
" <use x=\"68.499969\" xlink:href=\"#LibertinusSans-Regular-49\"/>\n",
" <use x=\"114.999954\" xlink:href=\"#LibertinusSans-Regular-50\"/>\n",
" <use x=\"161.499939\" xlink:href=\"#LibertinusSans-Regular-53\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <g id=\"LineCollection_1\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 59.198182 214.756364 \n",
"L 59.198182 190.047273 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 80.938442 214.756364 \n",
"L 80.938442 165.338182 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 102.678701 214.756364 \n",
"L 102.678701 140.629091 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 124.418961 214.756364 \n",
"L 124.418961 115.92 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 146.159221 214.756364 \n",
"L 146.159221 91.210909 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 167.899481 214.756364 \n",
"L 167.899481 66.501818 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 189.63974 214.756364 \n",
"L 189.63974 41.792727 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 211.38 214.756364 \n",
"L 211.38 17.083636 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 233.12026 214.756364 \n",
"L 233.12026 41.792727 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 254.860519 214.756364 \n",
"L 254.860519 66.501818 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 276.600779 214.756364 \n",
"L 276.600779 91.210909 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 298.341039 214.756364 \n",
"L 298.341039 115.92 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 320.081299 214.756364 \n",
"L 320.081299 140.629091 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 341.821558 214.756364 \n",
"L 341.821558 165.338182 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 363.561818 214.756364 \n",
"L 363.561818 190.047273 \n",
"\" style=\"fill:none;stroke:#348abd;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"line2d_19\">\n",
" <defs>\n",
" <path d=\"M 0 3 \n",
"C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
"C 2.683901 1.55874 3 0.795609 3 0 \n",
"C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
"C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
"C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
"C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
"C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
"C -1.55874 2.683901 -0.795609 3 0 3 \n",
"z\n",
"\" id=\"m59be4fe23f\" style=\"stroke:#348abd;\"/>\n",
" </defs>\n",
" <g clip-path=\"url(#pe6fa973d8a)\">\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"59.198182\" xlink:href=\"#m59be4fe23f\" y=\"190.047273\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"80.938442\" xlink:href=\"#m59be4fe23f\" y=\"165.338182\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"102.678701\" xlink:href=\"#m59be4fe23f\" y=\"140.629091\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"124.418961\" xlink:href=\"#m59be4fe23f\" y=\"115.92\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"146.159221\" xlink:href=\"#m59be4fe23f\" y=\"91.210909\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"167.899481\" xlink:href=\"#m59be4fe23f\" y=\"66.501818\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"189.63974\" xlink:href=\"#m59be4fe23f\" y=\"41.792727\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"211.38\" xlink:href=\"#m59be4fe23f\" y=\"17.083636\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"233.12026\" xlink:href=\"#m59be4fe23f\" y=\"41.792727\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"254.860519\" xlink:href=\"#m59be4fe23f\" y=\"66.501818\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"276.600779\" xlink:href=\"#m59be4fe23f\" y=\"91.210909\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"298.341039\" xlink:href=\"#m59be4fe23f\" y=\"115.92\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"320.081299\" xlink:href=\"#m59be4fe23f\" y=\"140.629091\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"341.821558\" xlink:href=\"#m59be4fe23f\" y=\"165.338182\"/>\n",
" <use style=\"fill:#348abd;stroke:#348abd;\" x=\"363.561818\" xlink:href=\"#m59be4fe23f\" y=\"190.047273\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"line2d_20\">\n",
" <path clip-path=\"url(#pe6fa973d8a)\" d=\"M 59.198182 214.756364 \n",
"L 363.561818 214.756364 \n",
"\" style=\"fill:none;stroke:#467821;stroke-linecap:square;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"patch_3\">\n",
" <path d=\"M 43.98 224.64 \n",
"L 43.98 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_4\">\n",
" <path d=\"M 378.78 224.64 \n",
"L 378.78 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_5\">\n",
" <path d=\"M 43.98 224.64 \n",
"L 378.78 224.64 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" <g id=\"patch_6\">\n",
" <path d=\"M 43.98 7.2 \n",
"L 378.78 7.2 \n",
"\" style=\"fill:none;stroke:#bcbcbc;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
" </g>\n",
" </g>\n",
" </g>\n",
" <defs>\n",
" <clipPath id=\"pe6fa973d8a\">\n",
" <rect height=\"217.44\" width=\"334.8\" x=\"43.98\" y=\"7.2\"/>\n",
" </clipPath>\n",
" </defs>\n",
"</svg>\n"
],
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"# roll two dice and sum\n",
"D8A = sympy.stats.Die(\"D8A\", 8)\n",
"D8B = sympy.stats.Die(\"D8B\", 8)\n",
"pmf = sympy.stats.density(D8A + D8B)\n",
"keys = pmf.keys()\n",
"plt.stem(list(keys), [pmf[k] for k in keys], use_line_collection=True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"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.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment