{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Probability"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The probability is a branch from statistics. We can rely on probabillity to predict what kind of value comes out from the population.Probability defines in mathematical formula as follow:\n",
"\n",
"$$0 \\leq P(A) \\leq 1$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For probability there are two popular definitions:\n",
"\n",
"* **frequentist interpretation**. It is the traditional method which explain the probability that observe a random process of infinite number of times, and get proportion of each of the outcomes out of all outcomes.\n",
"\n",
"* **bayesian interpretation**. It is the probability of two point of view observe an event. This maybe perhaps two different kind of view, a prior, which will be sometimes included in statistical inference, is a view before it's observe an event. And posterior, is the probability after observe an event. Bayesian method has been largely used in technology and methods for the last twenty years.\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Random Process"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Random Process is the process in which we know all possible outcomes, but don't which outcomes that will get out. You know two sides of coin, but don't know which side will come out in coin toss. Or a number that comes out in a dice, or a music comes out in your playlist. It's often useful if we random first our possible outcomes.\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Law of large numbers"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Law of large numbers states that if you observe a probability of an event, approach infinite number of times, the probability will converges to probability of an outcome. Say if you roll a dice and number 5 comes out, the probability of 6 will be 1. If you roll for the second time and 4 comes out, the probability comes out 6 will be 0.5. And if you roll thousands and thousands more, it will converge to the actual outcome, 1/6.\n",
"\n",
"The law stated that when sample size is few, the probability between events may because due to chance. But if the size is large, say over thousands, the probability won't likely happend due to chance. It's maybe usual to find 7 heads in 10 coin toss for fair coin, but unusual for 700 heads in 1000 toss."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Law of averages (gambler's fallacy)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Law of averages is on the other hand is oppose law of large numbers. Law of averages incorporates the observation that happen in the past. The probability of coin toss for tenth time is not suppose to remember the outcome for all previous nine toss. If thousands of coin toss but head still comes out, that it maybe not a fair coin. But it still doesn't remember for what occurs in the past. If observe, then the probability is times the previous one, is called law of averages."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### disjoint (mutually exclusive)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**disjoint** events can't happen in the same time. \n",
"\n",
"Example : A coin toss can't come out with head and tail. \n",
"\n",
"The formula then\n",
"\n",
"$$P(A and B) = 0$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**non-disjoint** events on the hand, can happen in the same time.\n",
"\n",
"Example: A worker is in the office for Monday and Tuesday.\n",
"\n",
"$$P(A and B) \\neq 0$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**union of disjoint events** is the probability of two or more disjoint events. For example,getting Jack and Three from well-shuffled deck of cards.For disjoint events A and B, the probability is simply sum of two events.\n",
"\n",
"$$P(A or B) = P(A) + P(B) $$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**union of non-disjoints events**, on the other hand is a little bit tricky, we want to subtract the probability of overlapping events, to avoid double counting.For non-disjoint events A and B,\n",
"\n",
"$$P(AorB) = P(A) + P(B) - P(AandB)$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w1.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/33) video, 05:11*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Overall disjoint events only need to remember about one thing. In this general formula, the overlapping events will be zero, and thus will get ignored."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w2.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/33) video, 05:11*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Sample Space"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Sample space is collection of all possible outcomes of a trial. If for example if the parents has two childs and predicts the outcome, we can make a trial to infer all possible outcomes.\n",
"\n",
" S = {MM, FF, FM, MF}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Probability distributions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Based on sample space that we gain earlier, we can make **probability distributions** which listed all possible outcomes and its respected probability. For example and rules:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w3.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/33) video, 07:07*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Complementary Events"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The complementary events is the sum of all the rest of the probability other than observed event. The complementary events of head occurs in one coin toss, is the probability of tail comes out. Two head-head event, the complementary events is the tail-tail, head-ail, and tail-head."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w4.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/33) video, 09:15*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So an event and its complementary events is always two disjoint events, and add up to 1. But the two disjoint event can't always add up to 1, since there might be other disjoint events. Republican and Democrat population can't be add up to 1, since there might be Other or Independent population."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Independence"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The two processes are known independent, if the outcome of the first one provide useless information to the second one. Here's the example:\n",
"\n",
"![jpeg](../galleries/coursera-statistics/2w6.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 01:17*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Coin Toss is always an independent outcomes. The draw of deck cards will become dependant, if the previous draw doesn't return back to the deck. In the right you see that Because Ace Red drawn from the first step, the probability of Ace Red in the second draw, will get affected, also in Jack Spades. 51 is number of cards after we pick the first draw and not returning it back."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The general formula then become, for checking an independence:\n",
" \n",
" If P(A|B) = P(A), then A and B are independent."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's take an example:\n",
"\n",
"![jpeg](../galleries/coursera-statistics/2w7.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 01:17*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" A : Race Ethnicity\n",
" B : 'protects citizens'\n",
" \n",
"Since the probability of P(A|B) $\\neg$ P(A), and it varies greatly for each of the A, then the two event is dependant. The probability will be the same regardless of the A, if the two events are independent."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the observation of difference among all outcomes, we're faced with additional steps.\n",
"\n",
"* Test those dependencies. If there's dependance,we may want to test that.If it's occurs or maybe there's only happen due to chance, we're doing hypothesis testing.\n",
"* For optional choice, without hypothesis testing, if the difference is large, then there's stronger evidence the differences are real\n",
"* For large sample, even if there's small difference, will give strong indicator that the difference may not happen due to chance."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If A and B are independent:\n",
"\n",
" P(A and B) = P(A) x P(B)\n",
" \n",
"The coin toss probability, the probability of two tails in a row, will be simply \n",
"\n",
" P(tail) x P(tail) = 0.5 * 0.5 = 0.25\n",
" \n",
"This happen if the probability of two coin comes out in a row, or at once. This could also work for infinite number of probability of independent events.\n",
"\n",
" If independent A1,..,Ak, P(A,..,Ak) = P(A) x P(..) x P(Ak)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's take an example:\n",
"\n",
"![jpeg](../galleries/coursera-statistics/2w8.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 01:17*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"From this example we can get some interesting information. If often useful that, in a lot of question, we're extracting some useful formation in a context of mathematical formula.\n",
"\n",
"We can pick the probability of being obesed is 33.5%. By asumming the that obesity rate stays constant, means that it doesn't change overtime, equals to what we get if we pick them at the same time. Two randomly selected make stronger evidence that this is independent. If it picked in a same household, then it will likely dependendat, as both may share the same food and sports activity.\n",
"\n",
"The probability results than as a given. Note that there's two advantage for calculating the probability:\n",
"\n",
"* Mathematical formula should prove that the product of less than 1 will be smaller. \n",
"* It can provide sanity check of your data, if you want to provide some additional practical probability to prove this. It does create advantage if you can design some mathematical formula to prove to your research results."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### The Probability Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w9.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 01:17*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this case, again we listed all useful information that we get from the stories. We have the probability of 'agree' from the population. We have 13.8% of uni degree. And the intersection between the two. Note that absolute value here, the number of people isn't our concern since we're given relative frequency by percentage, and questions that we want to ask is not about absolute value."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w10.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 01:17*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Since we are hinted at the intersection probability of two events, this two events are not disjoint events. Both events can happen at the same time."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w11.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 01:17*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To simplify the problem, we're gonna make a Venn diagram to visualize our problem. Doing this can make two advantage. First we can have easier understanding about the problem if we create a visualization. Second it will becomes as alternative calculation for our questions."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w12.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 04:28*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To solve these question, we can proceed with two options:\n",
"\n",
"* Calculate the results by using disjoint events formula. This will sum two events and subtract the intersection\n",
"* Using Venn diagram that we create earlier, summing all of the probability since we already get rid of the double counting(the intersection events)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w14.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 05:08*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The probability that it's asking is the probability of not A nor B happen. In this case, we can use complementary events, that is outside probability of all the probability events inside both our circle."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w15.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 06:07*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w16.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 06:07*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The probability of at least one agree, is the complementary events of all people disagree. Think about it. At least one people agree is higher probability than all 5 people disagree. Then we just take the highest probability which one people agree.\n",
"\n",
"Complementary of all people disagree is the answer we're looking for. If one people agree, or two people agree, or more is the complementary, the sum of the rest probability, of observed event all people disagree."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Disjoint vs Independent"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w17.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/35) video, 02:27*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Remember disjoint is about the the event which can't happen at the same time.Disjoint events can't happen at the same time. Using this provide critical information, that is because \"can't happen at the same time\", give indication that when first occurs the others can't occurs. This means that disjoint events are dependant.\n",
"\n",
"Independent is that event that provide no useful information to the other event.\n",
"\n",
"Looking at the baby's color eye example. When observing one baby, if the baby blue, he can't have other colors. This means it provide useful information, that baby has blue eye color.\n",
"\n",
"When we take two or more observed baby, then it becomes independent/dependant choice. If the baby is related or sibling, then it will be dependant of two events occurs. But if two babies are randomly selected from the population, then it will be independent events.\n",
"\n",
"Looking at the coin toss example, one coin toss will be dependant events, since head and tail are disjoint events, comes out head can't be comes out tail at the same time.Two coin toss is independent. First toss will not provide useful information for the second toss."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Conditional Probability"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w18.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/41) video, 01:15*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Study taken to include students in a survey, where by objective behind the scenes, the research has collected some information to determine whether the sudents is working class or upper middle class. Then students fills a survey to subjectively determine their own social class."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w19.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/41) video, 02:19*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Marginal Probability"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Marginal probability is the probability that comes incorporating the total. Here's because the question to ask is marginal probability of objective upper class, we're simply take proportion of objective upper class divided by total class.\n",
"\n",
"The objective upper class will be the total of all objective upper class, which is:\n",
"\n",
"$$P(obj UMC) = 50/98 \\approx 0.51$$\n",
" \n",
"The subjective upper middle class is:\n",
"\n",
"$$P(obj UMC) = 45/98 \\approx 0.46$$\n",
" \n",
"The probability of students that both meet criteria **subjective and objective** of upper middle class.\n",
"\n",
"$$ P(obj UMC \\& subj UMC) = 37/98 \\approx 0.38 $$\n",
"\n",
"We also can draw a Venn Diagram which put 37 in the intersection, 8 in subjective UMC, and 13 in objective UMC."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Conditional Probability"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w20.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/41) video, 04:29*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Conditional Probability is a probability that are given first in the condiion of the first events. \n",
"\n",
"Here if we look at the question, first we're looking at the objective working class, and select those subjective that are associates with upper middle class. Which in turn, given obj WC, which total of 48, select 8 of those. That will calculates the resulting probability."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The probability of students' given subjective upper middle class, which associates with objective upper middle class is:\n",
"\n",
"$$ P(subj MC \\mid obj UMC) = 13/50 \\approx 0.26$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The fact that we already have contigency table, simplify our calculation for calculating all the probability."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Bayes' theorem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Bayes can be used to solve this question. The formula is\n",
"\n",
"$$ P(A | B) = \\frac{P(A and B)}\n",
" {P(B)}$$\n",
" \n",
" \n",
"Where the denominator is the probability which we are condition on, the numerator is the joint probability. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w21.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/41) video, 06:15*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w22.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/41) video, 08:56*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we take the Bayesian to answer earlier question. This calculation is a little bit overkill because we alredy have the table. But if we don't have that, the Bayesian can calculate it for us."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here's another example that in this case we don't have contigency table. To calculate it, using Bayes' theorem, we arrive at conclusion that roughly 20% of the speak non-Eng live below property line.\n",
"\n",
"In this results, 20% out of all people that speaks other than English live below poverty line. 14.6% out of all people live below in poverty lines, which suggest there's maybe dependant probability of two events.\n",
"\n",
"If we're taking it backward, then out of all people live below povertly line, that also speaks other English is:\n",
"\n",
"\n",
"$$P(speak non-Eng \\mid below PL) = \\frac{P(below PL \\& speak non-Eng)} {P(speak non-Eng)} = \\frac{0.042}{0.146} \\approx 0.29$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w23.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/41) video, 09:36*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w24.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/41) video, 11:00*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we don't know the joint probability but not bayes probability, we can shuffle the formula and arrive at above conclusion."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"These are additional rules for proving whether the two events are independent or not. We can use Bayes' theorem and solve it by conceptually or mathemathically."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we have another contigency table that provide an example of independent event"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w25.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/41) video, 12:39*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we look briefly at the contigency table, where we have each of the total sum up to total of both events, we can see that the events are dependant. By proving it with Bayes's theorem, which resulting same probability of social class, regardless the gender, the gender and the major are independent events."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Probability Tree"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"PT is useful to checking reverse conditional probability.Take a look at this example, when you have absolute number of population."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w26.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/43) video, 02:48*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we can use Bayes theorem to solve this problem. Pay attention to the question that we really want to ask, since often it fails because of misunderstanding of the practioners. The question formulates to given 'free', what are the 'spam':\n",
"\n",
"This question will translate to:\n",
"\n",
"$$ P(spam \\mid \"free\") = \\frac{35}{35+3} \\approx 0.92$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we have another example that only give relative percentage."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w27.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/43) video, 05:07*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we can prove whether the test accuracy given real HIV/nonHIV. If the events are independent, the resulting probability should be the same. But in this case, P(+ | HIV) $\\neq$ P(-|non-HIV) which tells us that this is dependant event.\n",
"\n",
"\n",
" 0.259 HIV -- 0.997 positive\n",
" -- 0.003 negative\n",
" 0.741 non-HIV -- 0.074 positive\n",
" -- 0.926 negative\n",
" \n",
"Here's the more complete explanation of the probability tree. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w28.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/43) video, 10:07*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This results, shows that roughly 82% chance that tested positive have a HIV."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Bayesian Inference"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To explain in Bayesian Inference, we use 4 die and 12-die and set a game. The game only tells you provided that you choose either dice(you won't know which die) tells you that either more or less than 4. To explain more intuitively:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w29.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/45) video, 1:37*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The rule is that 6-die assigned to one hand side, and 12-die assigned to the other side. You can ask to roll a die, and yes/no question will comes out, either the resulting value comes out greater or nor than 4. There's a tradeback for the game, is that everytime you ask to roll, it costs money. This resembles the world problem that data cost money, larger data need larger resources.Your goal is to find the good die, and guess where the good die reside in which side of the hand."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before you ask to roll the die and collect any dat, both hands has equal chance, 50:50. Suppose we assigned hypothesis as follows:\n",
"\n",
"H1 : good die on the right\n",
"H2 : bad die on the right\n",
"\n",
"This probabilities is often called **prior**, we call that because you don't have any information to back up your probability guess."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w30.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/45) video, 11:17*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Round #1 : Turns out right hand spits greater than 1.We use probability tree and Bayes' theorem to solve our problem. The **posterior** probability, the probability after we gain information, should be as we expect, larger than 0.5.The posterior takes stronger ground in this rules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w31.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/45) video, 12:15*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The posterior will serve as our modal to create another prior in the next steps. This give us more and more probability, as we make iterative steps, converges to actual probability."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w32.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/45) video, 12:56*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After we have our posterior probability, in the next step we're updating our prior probability to have 0.6 chance of good die being in the right, and complementary probability in the left. Again we request for more roll, and calculate posterior probability and again, updating our prior.\n",
"\n",
"The Bayesian iterative steps is making repetitive of these steps:\n",
"\n",
" updating prior->calculating posterior->updating prior\n",
"\n",
"So how many steps do we need to make a guess? Do we have to wait until the our hypothesis reach 1? There's still fair chance that H2 is true, in this case, we can't wait the prior to finally get 1. It's up to us deciding what are the threshold faith probability. Do we want our probabilty to gain 80% confidence? 95% confidence? Remember that converging to 1 requires extra money, which you should pay attention to that."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w33.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/45) video, 14:14*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is a recap conclusion of what we just learn in Bayesian Inference. We take a more and more polished model as we calculate to update our prior probability. Note that prior probability can be any of your choice. But to make more fair prior values, we make educated guess, that in the beginning, all events should served equal chance.As we gain more data, our guess should matter less and less, as our probability will converges to actual probability.\n",
"\n",
"The Bayesian Inference should be not mistaken as p-value, where Bayes steps is to take more and more iterative steps to converge to actual probability, where p-value is taking one steps and observe the probability in extreme conditions given the Null Hypothesis is true."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here's another example using Bayesian Inference."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w34.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/47) video, 01:02*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w35.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/47) video, 01:32*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w36.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/47) video, 01:32*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![jpeg](../galleries/coursera-statistics/2w37.jpg)\n",
"\n",
"*Screenshot taken from [Coursera](https://class.coursera.org/statistics-003/lecture/47) video, 07:12*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So finally after our examples before, our iterative steps include:\n",
"\n",
"* setting a prior\n",
"* collecting data\n",
"* obtaining a posterior\n",
"* updating the prior with the previous posterior"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> **REFERENCES**:\n",
"\n",
"> * https://class.coursera.org/statistics-003/"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}