{ "cells": [ { "cell_type": "markdown", "id": "70e5327d-f8f8-4167-9c1d-7130d77c3b53", "metadata": {}, "source": [ "# 9.5 - Probability" ] }, { "cell_type": "code", "execution_count": null, "id": "aefb8b76-b877-4033-bf7d-aeb62ec1cf43", "metadata": {}, "outputs": [], "source": [ "from datascience import *\n", "import numpy as np" ] }, { "cell_type": "markdown", "id": "97ea4001-440c-4314-95d9-5022c693abb2", "metadata": {}, "source": [ "- P(event happens): the probability that an event happens\n", "- A probability is in the range [0,1]\n", "- P(event happens) = 1 - P(event doesn't happen)\n", "- If all events are equally likely, P(event happens) = # outcomes that make event happen / # total outcomes\n", "- Multiplication Rule: P(two events happen) = P(one event happens) * P(the other event happens, given that the first one happened)\n", "- Addition Rule: P(an event happens) = P(first way it can happen) + P(second way it can happen)\n", "- At Least One Success: P(an event occur in n independent trials) = 1 - P(an event doesn't occur in one trial) ^ n" ] }, { "cell_type": "code", "execution_count": null, "id": "07bdb3eb-9ad1-47aa-8bdd-aa618c519ae8", "metadata": {}, "outputs": [], "source": [ "rolls = np.arange(0, 201, 5)\n", "results = Table().with_columns(\n", " 'Card Draws', rolls,\n", " 'Chance of at least one Spade Ace', 1 - (51/52)**rolls\n", ")\n", "results" ] }, { "cell_type": "code", "execution_count": null, "id": "3cfa94e7-b29e-45ae-a716-5b000df604ce", "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "results.scatter('Card Draws')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.13.1" } }, "nbformat": 4, "nbformat_minor": 5 }