Lesson 10 – The fight for independence

I don’t have a “get out of jail free” card.

I don’t want to pay $50 to the bank because I am short on cash.

😉 I am trusting my magic dice to fight for my freedom. I know I will roll a double.

🙁 I am disappointed. As I wait for my turn, I realized that I did not kiss the dice before rolling. So I do it now and roll again.

😯 Maybe I should have kissed the dice two times since it is the second try. Oh, I did not pray before rolling. So I pray and roll the dice with optimism.

😡 I don’t believe this. My magic dice betrayed me. I will throw them away and get new ones.

Wait. The magic dice did not betray you. It is just following the probability rule for independent events. Unlike you, your magic dice does not have a memory. It does not know that the previous try was not a double. All it knows is that the probability of getting a double on any try is 16.66%.

Assume A is the event of seeing a double, and B is a previous event, say {6,1} – not a double.

The probability of getting a double given that the last try was not a double, P(A|B) is equal to the probability of getting a double in any try, P(A). P(A) does not depend on whether or not event B has happened. B does not influence A.

For independent events A and B, 
P(A|B) = P(A)

From lesson 9, conditional probability rule, we know that

P(A|B) = P(A ∩ B)/P(B)

We can combine these two and come up with a property for independent events.

P(A ∩ B) = P(A).P(B)

For independent events, the probability of both happening (A and B) is the product of the individual probabilities.

Let us apply this property to our example. What is the probability of not seeing a double in three consecutive rolls (with prayer 🙂 or without prayer)? In other words, what are the odds of missing three rounds of the game and paying $50 to get my freedom finally?

The probability of not seeing a double in any try is 30/36. 30 non-double outcomes in 36 possibilities. Since the events are independent, the likelihood of seeing three non-doubles is (30/36)(30/36)(30/36) ≅ 58%.

I should have known that before praying.

If the events are independent, they do not influence each other. A coin toss cannot affect a dice. Torrential rain in London may have nothing to do with the severe drought in California. Your actions may not influence my actions because we are independent.

We all like being independent … or the illusion of independence!

 

If you find this useful, please like, share and subscribe.
You can also follow me on Twitter @realDevineni for updates on new lessons.

Lesson 9 – The necessary ‘condition’ for Vegas

Joe and Devine meet again.

J: After our last discussion about probability, I now think in odds.

D: Go on.

J: I believe my decision making has improved. I react based on probability.

D: Great. Assuming you are making decisions for your benefit, in the  long run, you will be better off. Probability is the guiding force.

J: I am visiting Vegas next week. I want to use “the force” to outwit the house.

D: For that, the necessary condition is to know about conditional probability.

J: I know that probability is the long-run relative frequency. But what is conditional probability?

D: Since you are excited about Vegas, let us take the cards example.

Say, we have a deck of cards. If I shuffle and draw a card at random, what is the probability of getting a king?

J: Let me use my probability logic here. I will assume that the 52 cards will make up our sample space. Since there will be 4 kings in a deck of 52 cards, if your shuffling is fair, the likelihood of getting a king is 4/52.

D: Good. Let us call this event A → King.

What are the odds of getting a red card?

J: Since there will be 26 red cards in 52, the odds of getting a red card are 26/52.

D: Exactly. Let us call this event B → Red.

Now, If I draw a card at random, face down, and tell you that it is red, what is the probability that it will be a king?

J: So you are providing me some information about the card?

D: Yes, I am giving you a condition that the card is red.

J: Okay. Under the condition that the card is red, the odds of it being a king should be 2/26.

D: Can you elaborate.

J: Since you told me that the card is red, I only have to see how many kings are there in red cards. The sample space is now 26. There are two red kings. So the probability will be 2/26.

D: Good. Mathematically, this is written as

P(A|B) = P(A ∩ B) / P(B) 

or 

P(King | Red) = P(King and Red) / P(Red)

P(King and Red) is 2/52. P(Red) is 26/52. So we get 2/26.

J: I get it. My answer will depend on the condition. Can you provide one more example?

D: Sure. You told me that the probability of getting a king is 4/52. Suppose, this first card is faced up, and I draw another card face down. What is the probability that this second card is a king?

J: Since the first card is on the table and not replaced, the probability that the second card will be a king should be 3/51. Three kings left in the deck of 51.

D: Correct. The outcome of the second card is conditional on the outcome of the first card.

J: This makes perfect sense. If I can practice this counting and conditional probability, I can make some money on blackjack.

D: Yes you can. Knowing conditional probability is the necessary condition.

J: Why do you keep saying “necessary condition”?

D: Probability is your guiding force everywhere else in life.

But in Vegas, Joe Pesci is the force.

If you find this useful, please like, share and subscribe.
You can also follow me on Twitter @realDevineni for updates on new lessons.

Lesson 7 – The nervousness ‘axiom’ – fight or flight

“Professor, I am nervous about the test.”
“Professor, how should we study for the test?”
“Professor, what questions can we expect on the test?”
“Professor, what formulas will you provide on the test?”
“Professor, I am getting stressed out.”

I want to respond.

I know how you feel.
This response will not help because if I was taking a test, and I was nervous, I don’t need confirmation from my professor that he knows how I feel.

I have been in your shoes.” or “Been there, done that.
Really… besides not helping, this response will make them angry. I am not in their shoes now, and who cares if I have done it before.

You are on your own. Go figure it out.
No, I am on their side, and we are taking down the data analysis beast together.

Since the responses are not working, I provide a way to think probabilistically.

Let us say there are 15 questions that you need to study for the test. These 15 questions are our sample space.

The probability of the sample space is 1 — Probability Axiom 1

The likelihood of being tested from these 15 questions is 1. You cannot escape this unless you decide to skip the test.

Let us now group these questions into concepts. Suppose there are three concepts, Concept A, Concept B and Concept C. Go through each question and identify to which concept it belongs. For instance,

We see that six questions belong to concept A, seven questions belong to concept B, and five questions belong to concept C. Three questions have both concept A and concept B. Switch to a visual mode – you will see this.

By now, you should know that the probability of getting a question from concept A is 6/15 = 0.4, the probability of getting a question from concept B is 7/15 = 0.466, and the probability of getting a question from concept C is 5/15 = 0.333.

Underlying this number is the rule that the probability of any event in the sample space is between 0 and 1 — Probability axiom 2.

In other words, if there were no questions that belonged to concept A, then, the probability would have been 0 (0/15). If all the 15 questions were from concept A, the probability would have been 1 (15/15).

Let us now think about the probability of getting a question from concept A or concept C. 11 questions in total belong to concept A or concept C; six from A and five from C. Hence, the probability of getting a question from concept A or concept C is

In this example, there are no questions that have both concept A and concept C. They are disjoint sets. For disjoint or mutually exclusive events, the probability that one or the other of the two events occurs is the sum of their individual probabilities — Probability axiom 3.

Let us extend this understanding to the probability of getting a question from concept A or concept B. if you look at the Venn diagram above; you will see that there are 3 + 3 + 4 questions that are either concept A or concept B or both. Hence, the probability of getting a question from concept A or concept B is

Since three questions belong to both A and B (i.e., the intersection of A and B), it will be sufficient to count them once. In the equation, you are adding the probability of A (6 questions out of 15), to the probability of B (7 questions out of 15), and subtracting the intersection (3 common questions out of 15) to avoid double counting.

Now that the ground rules (Axioms of Probability) are set, all you need to do is calculate the probability of getting exactly one question from binomial distribution in a total of 5 questions and hope your prediction will come true! That was for my friends in the class.

Oh, I love this game. They anticipate my behavior and predict the probability of getting any question. I anticipate that they do this, hence, try to outsmart them.

I get a sense that my folks figured out the pattern here. Beavers are Strivers. Wikipedia also tells me that beavers build dams, canals, and lodges.

 

If you find this useful, please like, share and subscribe.
You can also follow me on Twitter @realDevineni for updates on new lessons.

Lesson 6 – It’s ‘probably’ me

Let me introduce you to two friends, Joe and Devine.

Joe is a curious kid, funny, feisty and full of questions. He is sharp and engaging and always puts in the honest effort to understand things.

Devine is mostly boring, but thoughtful. He believes in reason and evidence and the scientific method of inquiry.

Joe and Devine stumbled upon our blog and are having a conversation about Lesson 5.

Joe: Have you seen the recent post on data analysis classroom. There was an interesting question on how many warm days are there in February.

Devine: What do you mean by warm? Where is it warm?

Joe: Look, Devine, I know you always want to think from first principles. Can you stop being picky and cut to the chase here.

Devine: Okay, how many warm days are there in February?

Joe: Looks like there were seven warm days last month. That seems like a high number.

Devine: Maybe. Do you know the probability of warm days in February?

Joe: What is “probability“?

Devine: Let us say it is the extent to which something is probable. How likely is a warm day in February? In other words, how frequently will warm day occur in February?

Joe: I can see there are seven warm days in February out of 28 days. So that means the frequency or likeliness is seven in 28. 7/28 = 0.25. So the probability is 25%.

Devine: What you just computed is for February 2017. How about February 2016, 2015, 2014, 2013, … ?

Joe: I see your point. When we compute the frequency, we are trying to see how many times an event (in this case warm day in February) is occurring out of all possibilities for that event.

Devine: Yes. Let us say there is a set of February days; 28 in 2017, 29 in 2016, 28 in 2015, so on and so forth. These are all possible February days. Among all these days, we see how many of them are warm days.

Joe: So you mean what is the frequency in the long run.

Devine: Yes, the probability of an event is its long-run relative frequency.

Joe: Let me get the data for all the years and see how many warm days are there in February.

Devine: That is a good idea. When you get the data, try the following experiment to see how the probability approaches the true probability as you increase the sample space.

Step 1: Compute the number of warm days in February 2017. Let us call this warmdays2017. So the probability of warm days is p = warmdays2017 divided by 28.

Step 2: Compute the number of warm days in February 2016. Let us call this warmdays2016. Using this extended sample size, we calculate the probability of warm days as p = (warmdays2017 + warmdays2016) divided by 57; 28 days in 2017 and 29 days in 2016. Here you have more outcomes (warm days) and more opportunities (February days) for these outcomes.

Step 3: Do this for as many years as you can get data, and make a plot (visual) of growing years and true probability.

Joe: I got the logic, but this looks like a lot of counting for me. Is there an easier way?

Devine: R can help you do this easily. Perhaps, you can wait till the data analysis guy posts another lesson of tricks in R. For now, let me help you.

Joe: Great.

Devine: Okay, here is what I got after running this experiment.

Joe: This is pretty. Let me try to interpret it. On the x-axis you have Years up to; and the axis is showing 2017, 2016, …, 1949. So that means, in each step, you are considering the data up to that year — up to 2017, up to 2016, up to 2015 so on and so forth. On the y-axis, you have the probability of warm days in February. At each step, you are computing the probability with new sample size, so you have a better idea of the likelihood of warm days since there are more outcomes and opportunities.

Devine: Exactly. What else do you observe?

Joe: There is a red line somewhere around 0.02, and the probabilities are approaching this red line as we have more sample size.

Devine: Great, the red line is at 0.027, and the long run relative frequency — Probability of warm days in February is 0.027. Notice that the probability does not vary much, and looks like a stable line after you go up to 2000s. This is telling us that we need enough sample size to get a reliable measure of the probability.

Joe: What happens to the probability if we have 50 more years of data?

Devine: ah…

Joe: Wait, I thought the probability based on 2017 data is 0.25. Why is the first point on the plot at 0.15?

Devine: Joe, you are the curious kid.. Go figure it out.

In case you are wondering who Devine is,

It’s probably me.

 

If you find this useful, please like, share and subscribe.
You can also follow me on Twitter @realDevineni for updates on new lessons.

Lesson 4 – I am a visual person

So am I. Aren’t we all? Our brain likes it that way.

Let us activate our visual cortex to learn more about Sets. Imagine that you are taking a headcount for high school or college intramurals. You have players who are interested in basketball and players who are interested in soccer. Some of them are interested in participating in both basketball and soccer.

Let us ask them to organize themselves into the basketball and soccer teams. A simple visual of this would look like:

Let us call our basketball players Team Basket (B). Let us call our soccer players Team Soccer (S). Let us call all of them Team Intramural (I).
If Team Intramural is the set of all players interested in participating in sports, Team Basket and Team Soccer are subsets of Team Intramural. All the players in Team Basket and Team Soccer also belong to Team Intramural.

All players who do not play soccer are the complement of Team Soccer. The complement of a set is used to denote everything but the set.

If you want to know how many players are interested in basketball or soccer, you can visualize the entire space that includes Team Basket or Team Soccer. The union of these two teams or set.

If you want to know how many players are interested in basketball and soccer, you can visualize the space that includes players that like to participate in both. The individuals who intersect the two teams.

If you want to take a count of players interested in only one sport but not both, you can visualize a space that includes players that like basketball or players that like soccer, but the players that like both will miss out. This grouping is also called symmetric difference, or the Union – Intersection.

Now imagine another class of students approached you inquiring about field hockey. Let us call this new team, Team Hockey. Team Hockey will become a subset of Team Intramural. However, the players of Team Hockey and the players of Team Soccer do not have anything in common. They are mutually exclusive. They are disjoint. They don’t cross lines — their intersection is 0.

Next week, we will learn how to use real data in RStudio, how to categorize the data into sets, and how to check for intersections, unions, and exclusiveness. In the meantime, try to visualize how our players and teams fit these other Set Properties.

If the union of all sets makes up the entire space, then the sets are collectively exhaustive. Our Team Soccer, Team Basketball, and Team Hockey are collectively Team Intramural (Exhaustive).

I finally think my students got the idea of mutually exclusive and collectively exhaustive sets when I told them that the mid terms are mutually exclusive, but the final exam is collectively exhaustive !! They must have visualized the final.

 

If you find this useful, please like, share and subscribe.
You can also follow me on Twitter @realDevineni for updates on new lessons.

Lesson 3 – The ‘Set’up

We begin our quest with the idea of classifying things. Whether it is Aristotle grouping animals into those living in water and those living on land, or you and me grouping our daily activities into those best done in the morning and those best done in the evening, we are all obsessed with putting things in order – into blocks — groups — SETS.

Math puritans can start with Georg Cantor’s Set Theory. Others can think of SET as a collection of distinct elements.

The fruit basket in your house is a set of fruits consisting of apples, bananas, and grapes – {apple, banana, grapes}.

After work, you can visit a local hangout place where you find a set of people interested in alcohol or food or both.

The vowels in English alphabets are a set {a, e, i, o, u}. The English alphabets are a set {a, b, c, …, x, y, z}.

The outcomes of a coin toss are a set {Head, Tail}.

In the game of Monopoly, you move by the outcomes of the dice. These outcomes are a set of number combinations – {(1,1), (1,2) … (6,6)}.

We all tried rolling a double to get out of jail. Did you know that the odds of getting out of jail by rolling a double are only 16.6%?

There are six possible doubles (see the red background combinations along the diagonal – {(1,1), (2,2), (3,3), (4,4), (5,5), (6,6)}) when you roll two dice. The entire set of possible combinations are 36. The odds are 6/36. Maybe you should have paid the $50 to get out of jail immediately.

Think about sets and possible outcomes in whatever you do this week — Happy President’s Day.

Speaking of Presidents, you should have already imagined a Set of

 

If you find this useful, please like, share and subscribe.
You can also follow me on Twitter @realDevineni for updates on new lessons.

Lesson 1 – When you see something, say data

Data is the key to understanding patterns, learning about behaviors, testing your theories, and supporting your arguments. It provides an entry point to get a general idea about anything. Make a commitment to yourself that you will think about data when you see something. Here, I provide some common situations to prime the pump.

  • Preferred Coffee: I am writing this post from a coffee shop. My favorite coffee is espresso. I am curious about what others visiting this shop prefer. I can either sit all day and watch what they buy (which will get the manager suspicious) or ask the cashier about how many people purchased espresso or other coffee (tell them it’s a scientific experiment first!).

  • Cars and Tolls: We all waited in line to pay the toll to use the bridge. Friends from the tri-state area are thinking EZPASS. Yes, next time you pass a toll, think about how many cars pass the toll in a day. We can use this data to understand how many people use the bridge and how much revenue it generates.

  • Fitbit: Look at your Fitbit or smartphone health app. Tell me how many hours your sleep on average.

  • You get the point.

 

If you find this useful, please like, share and subscribe.
You can also follow me on Twitter @realDevineni for updates on new lessons.

error

Enjoy this blog? Please spread the word :)