Last active
February 20, 2020 00:37
-
-
Save brianspiering/4c7dcf9a92070d0c0c17f5c270ff2746 to your computer and use it in GitHub Desktop.
Empirical joint vs conditional probability for a dataset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Joint vs Conditional Probability\n", | |
"-------" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"toc": true | |
}, | |
"source": [ | |
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n", | |
"<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Joint-vs-Conditional-Probability\" data-toc-modified-id=\"Joint-vs-Conditional-Probability-1\">Joint vs Conditional Probability</a></span></li><li><span><a href=\"#Learning-Outcomes\" data-toc-modified-id=\"Learning-Outcomes-2\">Learning Outcomes</a></span></li><li><span><a href=\"#Joint-Probability-\" data-toc-modified-id=\"Joint-Probability--3\">Joint Probability </a></span></li><li><span><a href=\"#Conditional-probability-distribution\" data-toc-modified-id=\"Conditional-probability-distribution-4\">Conditional probability distribution</a></span></li><li><span><a href=\"#Empirical-Data--\" data-toc-modified-id=\"Empirical-Data---5\">Empirical Data </a></span></li><li><span><a href=\"#Joint-probability-distribution-p(x,y)\" data-toc-modified-id=\"Joint-probability-distribution-p(x,y)-6\">Joint probability distribution p(x,y)</a></span></li><li><span><a href=\"#Conditional-probability-distribution-p(y|x)\" data-toc-modified-id=\"Conditional-probability-distribution-p(y|x)-7\">Conditional probability distribution p(y|x)</a></span></li><li><span><a href=\"#Another-Problem\" data-toc-modified-id=\"Another-Problem-8\">Another Problem</a></span></li><li><span><a href=\"#-Outcome-Table\" data-toc-modified-id=\"-Outcome-Table-9\"> Outcome Table</a></span></li><li><span><a href=\"#Joint-probability-distribution\" data-toc-modified-id=\"Joint-probability-distribution-10\">Joint probability distribution</a></span></li><li><span><a href=\"#Conditional-probability-distribution\" data-toc-modified-id=\"Conditional-probability-distribution-11\">Conditional probability distribution</a></span></li></ul></div>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"<center><h2>Learning Outcomes</h2></center>\n", | |
"\n", | |
"__By the end of this session, you should be able to__:\n", | |
"\n", | |
"- Calculate the joint and conditional probability distribution for a given dataset.\n", | |
"- Describe the difference in your own words." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "fragment" | |
} | |
}, | |
"source": [ | |
"Joint Probability \n", | |
"------\n", | |
"\n", | |
"How likely will two events both happen?\n", | |
"\n", | |
"p(x , y)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "fragment" | |
} | |
}, | |
"source": [ | |
"Conditional probability distribution\n", | |
"---------\n", | |
"\n", | |
"How likely will one event happen given a different event happened?\n", | |
"\n", | |
"p(y ❘ x)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"Empirical Data \n", | |
"-------\n", | |
"\n", | |
"| x | y | \n", | |
"|:-------:|:------:|\n", | |
"| 1 | 0 |\n", | |
"| 1 | 0 |\n", | |
"| 2 | 0 |\n", | |
"| 2 | 1 |\n", | |
"\n", | |
"Create the following tables:\n", | |
"\n", | |
"- __Joint probability distribution p(x,y)__ \n", | |
"- __Conditional probability distribution p(y|x)__" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "skip" | |
} | |
}, | |
"source": [ | |
"__Joint probability distribution p(x,y)__:\n", | |
"\n", | |
"| __p(x,y)__ | y=0 | y=1 | \n", | |
"|:-------:|:------:|:------:|\n", | |
"| x=1 | ? | ? |\n", | |
"| x=2 | ? | ? |\n", | |
"\n", | |
"\n", | |
"__Conditional probability distribution p(y|x)__:\n", | |
"\n", | |
"| __p(y ❙ x)__ | y=0 | y=1 | \n", | |
"|:-------:|:------:|:------:|\n", | |
"| x=1 | ? | ? |\n", | |
"| x=2 | ? | ? |" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"Joint probability distribution p(x,y)\n", | |
"------\n", | |
"\n", | |
"| __p(x,y)__ | y=0 | y=1 | \n", | |
"|:-------:|:------:|:------:|\n", | |
"| x=1 | 1/2 | 0 |\n", | |
"| x=2 | 1/4 | 1/4 |\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Conditional probability distribution p(y|x)\n", | |
"------\n", | |
"\n", | |
"| __p(y ❙ x)__ | y=0 | y=1 | \n", | |
"|:-------:|:------:|:------:|\n", | |
"| x=1 | 1 | 0 |\n", | |
"| x=2 | 1/2 | 1/2 |" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"Another Problem\n", | |
"------\n", | |
"\n", | |
"X(n) will be True (or 1) when n is even. \n", | |
"Y(n) will be True (or 1) when n is prime.\n", | |
"\n", | |
"Make the following tables:\n", | |
"\n", | |
"1. Outcome table\n", | |
"1. Joint probability distribution\n", | |
"1. Conditional probability distribution" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
" Outcome Table\n", | |
" ----\n", | |
"\n", | |
"| n | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |\n", | |
"|:-------:|:------:|:------:|:------:|:------:|:------:|:------:|:------:|:------:|\n", | |
"| X | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |\n", | |
"| Y | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 |" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"Joint probability distribution\n", | |
"------\n", | |
"\n", | |
"| __p(x,y)__ | x is True (1) | x is Not True (0) | \n", | |
"|:-------:|:------:|:------:|\n", | |
"|Y is True (1) | TODO | TODO |\n", | |
"| y is Not True (0) | TODO | TODO | " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Conditional probability distribution\n", | |
"------\n", | |
"\n", | |
"| __p(x ❙ y)__ | x is True (1) | x is Not True (0) | \n", | |
"|:-------:|:------:|:------:|\n", | |
"|Y is True (1) | TODO | TODO |\n", | |
"| y is Not True (0) | TODO | TODO | " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"<br>\n", | |
"<br>" | |
] | |
} | |
], | |
"metadata": { | |
"anaconda-cloud": {}, | |
"celltoolbar": "Slideshow", | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.6" | |
}, | |
"toc": { | |
"base_numbering": 1, | |
"nav_menu": {}, | |
"number_sections": false, | |
"sideBar": false, | |
"skip_h1_title": false, | |
"title_cell": "Table of Contents", | |
"title_sidebar": "Contents", | |
"toc_cell": true, | |
"toc_position": {}, | |
"toc_section_display": true, | |
"toc_window_display": false | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment