{ "cells": [ { "cell_type": "markdown", "metadata": { "tags": [ "s1", "content", "l1" ] }, "source": [ "# Theory of Probability\n", "\n", "
\n", "## Probability Spaces\n", "\n", "A probability space is defined as a triple $(\\Omega, E, P)$, where $\\Omega$ is a set of outcomes(also called sample space), $E$ is an event space, and $P$ is a probability function that maps $E \\to [0, 1]$. Consider an experiment where two coins are tossed. The $\\Omega$ is then:\n", "* (H, T)\n", "* (T, H)\n", "* (T, T) \n", "* (H, H) \n", "\n", "given that 'H' is a \"heads\", and \"T\" is a \"tails\".\n", "\n", "A probabilistic model involves a process known as the experiment, which produces exactly one out of all the possible outcomes in the sample space. This subset of the sample space is known as an event. There is always only one experiment. Sample space may consist of finite or infinite number of outcomes. \n", "\n", "$F$, an event can be defined when two heads or two tails occuring together. $F$ would be a subset of $\\Omega$ outcomes consisting of:\n", "\n", "* (H, H)\n", "* (T, T)\n", "\n", "\n", "\n", "The countable additivity property would therefore allow a computation of the probability of the occurence of the event as shown:\n", "\n", "\n", "\n", "$P$ would therefore be:\n", "\n", "$$P = \\frac{No. of Events}{No. of Outcomes}$$
\n", "$$P = \\frac{1}{4} + \\frac{1}{4} = \\frac{1}{2} = 0.5$$\n", "\n", "\n", "\n", "### Exercise\n", "\n", "Consider an experiment where two dice are rolled. \n", "* How many sets would be contained in the sample space? Assign this to the variable space_size." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true, "tags": [ "s1", "ce", "l1" ] }, "outputs": [], "source": [ "# Complete the assignment below.\n", "# space_size = ?" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "s1", "l1", "hint" ] }, "source": [ "The samples should be combinations of 6*6" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [ "s1", "l1", "ans" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Sample Size is 36\n" ] } ], "source": [ "space_size = 36\n", "print(\"Sample Size is \", space_size)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "tags": [ "s1", "hid", "l1" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "continue\n" ] } ], "source": [ "ref_tmp_var = False\n", "\n", "try:\n", " if space_size == 36:\n", " ref_assert_var = True\n", " ref_tmp_var = True\n", " else:\n", " ref_assert_var = False\n", " print('Please follow the instructions given and use the same variables provided in the instructions. ')\n", "except Exception:\n", " print('Please follow the instructions given and use the same variables provided in the instructions. ')\n", "\n", "assert ref_tmp_var" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "l2", "content", "s2" ] }, "source": [ "\n", "
\n", "## Random Variable\n", "\n", "Given an experiment and set of possible outcomes, random variable associates a particular number to each outcome. Consider an event where a coin is tossed twice. The random variable where number of Heads occur is denoted as:\n", "$$ X \\to \\{0, 1, 2\\}$$ \n", "Random variables can be either continuous or discrete. A random variable is discrete if its range is finite or at most countably infinite. A random variable is continuous if it can take uncountably infinite number of values.\n", "\n", "\n", "\n", "### Exercise\n", "\n", "* What is the random variable that would take the sum of two dice? Assign the values to a list, S." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true, "tags": [ "l2", "ce", "s2" ] }, "outputs": [], "source": [ "S = []" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "l2", "s2", "hint" ] }, "source": [ "Use range() and list() functions." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "tags": [ "l2", "s2", "ans" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n" ] } ], "source": [ "S = list(range(2, 13))\n", "print(S)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "tags": [ "l2", "hid", "s2" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "continue\n" ] } ], "source": [ "ref_tmp_var = False\n", "\n", "import numpy as np\n", "\n", "try:\n", " if np.all(S == list(range(2, 13))):\n", " ref_assert_var = True\n", " ref_tmp_var = True\n", " else:\n", " ref_assert_var = False\n", " print('Please follow the instructions given and use the same variables provided in the instructions. ')\n", "except Exception:\n", " print('Please follow the instructions given and use the same variables provided in the instructions. ')\n", "\n", "assert ref_tmp_var" ] } ], "metadata": { "executed_sections": [], "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.6.0" } }, "nbformat": 4, "nbformat_minor": 2 }