{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"remove_cell"
]
},
"outputs": [],
"source": [
"# HIDDEN\n",
"from datascience import *\n",
"from prob140 import *\n",
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"plt.style.use('fivethirtyeight')\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Probabilities as Proportions ##"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can think of probability as a numerical measure of uncertainty. Exactly what this means is the subject of considerable philosophical debate which we will touch on from time to time. For now, it is reassuring to note that almost all sides in the debate agree on some basic computational principles. Indeed, these principles have been known to gamblers through the ages.\n",
"\n",
"To state the principles it helps to have some terminology and notation. In this section we'll just set these up informally and get a taste of some of the considerations that are involved in calculating chances. In later sections we will work more formally and in greater generality."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Terminology ###\n",
"\n",
"An *experiment* is any activity that involves an element of chance. When you perform the experiment there is an *outcome* which is the result of the experiment. \n",
"\n",
"Thus for example rolling a six-sided die once is an experiment. You can think of the outcome as an integer in the range 1 through 6, corresponding to the number of spots on the face of the die that appears on the roll.\n",
"\n",
"An *event* is a description of the result of the experiment, which could be more broad than just a single outcome. For example, \"the die shows a multiple of 3\" is an event. This event happens if the die shows either 3 or 6.\n",
"\n",
"**Language note:** The word *die* is singular. The word *dice* is the plural of *die*. You can have one die or two dice. But you cannot have one dice. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Assumption of Equally Likely Outcomes ###\n",
"\n",
"Here's a question for you:\n",
"\n",
"What is the chance that the die shows a multiple of 3? \n",
"\n",
"Did you answer, \"2 out of 6, or 1/3, because it's two faces out of six faces\"?\n",
"\n",
"If you did, pause for a second and examine what you hid in that answer. Notice that **you assumed that all six faces have the same chance, and that the chance is just a simple proportion.**\n",
"\n",
"That's a fine way to start, but it is important always to be aware that **probabilities depend on the assumptions that have been made, and if the assumptions are wrong then the answers can't be trusted**. \n",
"\n",
"After all, you haven't seen the die. It might be a trick die that is loaded in some way to show some faces more often than others.\n",
"\n",
"But for now let's assume that the die is fair. That is, we will assume that all six faces are equally likely to appear on the roll. In this class, the word \"die\" used without any qualification will mean \"fair six-sided die\". "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Proportions ###\n",
"Gamblers through the ages would agree with your calculation of \"2 out of 6\" for the chance that the die shows a multiple of 3, assuming that the die is fair.\n",
"\n",
"In general, *if an experiment has a finite number of equally likely outcomes,* then the probability of an event is defined as *the proportion of outcomes that are included in the event*.\n",
"\n",
"No matter whether the die is fair or loaded, the event \"the die shows a multiple of 3\" consists of two outcomes: 3 and 6. If the die is fair then the probability of the event is the proportion 2/6 by the definition above.\n",
"\n",
"We will usually shorten this to $P(\\text{die shows a multiple of 3}) = 2/6$. That's $P$ for probability, of course.\n",
"\n",
"You are welcome to write the answer as \"2 out of 6\" or \"1/3\" or \"33.333...%\" or \"0.333...\" or any equivalent way of representing the proportion."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Teen Use of Online Platforms ###\n",
"Coins, dice, cards, and other games of chance provide wonderful examples that illuminate properties of probability. We will use them frequently for that purpose. But data scientists typically work in other settings. Ideas developed in the context of games of chance can be translated, with appropriate care, into those settings to help data scientists gain insights about the data.\n",
"\n",
"The [Pew Research Center](https://www.pewresearch.org/) is an organization that conducts surveys on the opinions and choices of people in the U.S. In Spring 2018 it [surveyed U.S. teens](https://www.pewinternet.org/2018/05/31/teens-social-media-technology-2018/) (ages 13 through 17) about their use of online platforms such as YouTube and Facebook.\n",
"\n",
"The graphic below displays some of the results of the survey. For now, set aside questions about the accuracy of the survey across the U.S; we will discuss sampling accuracy later in the course. Just consider a population of teens whose online platform usage is summarized by these graphs.\n",
"\n",
"![online platform_use](../images/online_platforms.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are two bar charts. Each displays percents of teens over categories that are online platforms. Note \"None of the above\" as the category at the bottom of both. The teens in those bars are the same in both charts and constitute 3% of all the teens."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Distribution ###\n",
"Though the two bar charts cover the same categories, there is an important difference between them. Read the Note that the Pew Research Center included below the graphs.\n",
"\n",
"The chart on the right displays the answer to a question that asked which *one* of the platforms was most commonly used by the teen respondent. Each teen picked one and only one such platform. *Thus each teen is represented in exactly one of the bars.* For example, the group that said they used Facebook most often has no members in common with the group that said they used Twitter most often.\n",
"\n",
"That is why the percents in the bars of the right hand chart add up to 100 (apart from rounding). We say that the chart represents a *distribution* of teens over the categories. In a distribution, each individual appears in one and only one category.\n",
"\n",
"In the chart on the left, teens can appear in more than one category because they were identifying which platforms they used and were allowed to list more than one. Because the groups in the different categories overlap, the percents add up to more than 100. This bar chart does not represent a distribution."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Complements ###\n",
"Now assume you are picking one teen at random from the population represented in these charts. That is short for assuming that each teen has the same chance of being picked as every other teen in the population.\n",
"\n",
"Because all the outcomes (teens!) are equally likely, probabilities are just percents of teens. Let's use the charts to find some chances.\n",
"\n",
"**Question 1:** What is the chance that the chosen teen used Facebook most often? \n",
"\n",
"**Answer:** This can be read off the right hand chart: $P(\\text{used Facebook most often}) ~ = ~ 0.1$\n",
"\n",
"**Question 2:** What is the chance that the chosen teen did not use Facebook most often? \n",
"\n",
"**Answer:** The group that did not use Facebook most often consists of everyone but those who used Facebook most often. In the language of set theory, these two groups are called *complements* of each other. Their two proportions must add up to 1. So: $P(\\text{did not use Facebook most often}) ~ = ~ 1 - 0.1 ~ = ~ 0.9$\n",
"\n",
"**Question 3:** What is the chance that the student used Facebook but used some other platform more often?\n",
"\n",
"**Answer:** Now we have to use the information in both graphs. The left hand graph says that 51% of the teens used Facebook. We already saw that 10% of the teens used Facebook most often. *This group used Facebook*, so it is part of the 51% that used Facebook.\n",
"\n",
"Who were the other 41%? That's right – they used Facebook, but not most often. That's exactly the group whose proportion we are trying to find. It can be thought of as the complement of those who used Facebook most often *but only among those who used Facebook*.\n",
"\n",
"In summary, \n",
"\n",
"$$\n",
"\\begin{align*}\n",
"& P(\\text{used Facebook but used some other platform more often}) \\\\\n",
"&= ~ 0.51 - 0.1 ~ = ~ 0.41\n",
"\\end{align*}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Conditioning ###\n",
"Probabilities of events can be affected by information about the occurrence of other events. For example, suppose as before that someone picks a teen at random from the population represented in the charts. And now suppose that they tell you that the teen used Facebook.\n",
"\n",
"**Question 4:** Given this information, what is the chance that the teen used Facebook most often?\n",
"\n",
"**Answer:** Go back and look at the left hand chart. You know that the selected teen is in the Facebook bar of the chart. So you can forget all the other bars. *You are now working with a restricted set of outcomes:* the outcomes corresponding to the given information, which is that the teen used Facebook.\n",
"\n",
"The teens who used Facebook most often are a subset of this group, as observed earlier and shown in the figure below. It's just a rough Venn diagram that uses circles instead of bars. We'll be sketching a lot of these, and you should too.\n",
"\n",
"![Venn diagram](../images/venn_conditioning.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The total number of outcomes is now the \"used FB\" group, which comprises 51% of the original total number of teens. If you prefer counts to percents, you can pretend that there were 100 teens in all, and that thus there were 51 teens who used Facebook. \n",
"\n",
"The right hand chart says that the teens who used Facebook most often are 10% of the entire population, that is, 10 out of 100 imagined teens.\n",
"\n",
"We can now put all these observations together to find the chance in question. Given that the selected teen used Facebook, the chance that they used Facebook most often is\n",
"\n",
"$$\n",
"\\frac{\\text{10% of original total}}{\\text{51% of original total}} ~ = ~ \\frac{0.1}{0.51} ~ = ~ \\frac{10}{51} ~ \\approx ~ 0.196 \n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is called the *conditional probability that the teen used Facebook most often, given that they used Facebook*. That's pretty long, so some notation is helpful. This conditional probability is written as\n",
"\n",
"$$\n",
"P(\\text{used Facebook most often} \\mid \\text{used Facebook})\n",
"$$\n",
"\n",
"The vertical bar is read as \"given that\". \n",
"\n",
"To find a conditional probability:\n",
"\n",
"- First restrict the set of all outcomes as well as the event to only the outcomes that satisfy the given condition\n",
"- Then calculate proportions accordingly"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Compare the answers to Questions 1 and 4 to see how additional information about the outcome affects the probability of an event.\n",
"\n",
"- $P(\\text{used Facebook most often}) = 0.1$\n",
"- $P(\\text{used Facebook most often} \\mid \\text{used Facebook}) \\approx 0.196 \\approx 0.2$\n",
"\n",
"The second answer is about double the first. \n",
"\n",
"The answer to Question 1 is 10% (out of the original population). The answer to Question 4 is that same 10% relative to about half of the original population, because about half the original population used Facebook. That makes the answer to Question 4 about double the answer to Question 1.\n",
"\n",
"The probability of \"used Facebook most often\" changes based on the given information, because knowing that the selected teen used Facebook restricts the possible outcomes to about half of the original population."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"celltoolbar": "Edit Metadata",
"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.11"
}
},
"nbformat": 4,
"nbformat_minor": 4
}