<jupyter_start><jupyter_text>Dependence and IndependenceDifferent random phenomena often depend on each other in obvious or subtle ways. *Conditional probability* is the study of such dependence. This is one of the most important concepts in probability. In fact, it is often said that “all probabilities are conditional”, which means that we should always understand probability through the concepts taught in this chapter. Some examples of how we can use conditional probabilities are:* In null hypothesis testing, we are asking whether an observed difference in a summary statistic **depends** on the underlying grouping of the data. This dependence can be best expressed in terms of conditional probabilities and conditional expectations.* In wireless communications, we receive a noisy signal and need to determine which information symbol was transmitted. The noisy signal **depends** on the transmitted information, and thus we can use tools from conditional probability to make optimal decisions about the transmitted symbol.* In compound experiments, the later experiments often **depend** on the results of the earlier experiments. For instance, consider drawing cards from a deck. If the first card is an ace, then the probability that second card will be an ace is different than if the first card had not been an ace.In this chapter, I will introduce tools for working with conditional probability. These tools will often help us answer questions that are challenging to understand without conditional probability. Below I give a few quick examples of simple problems that people often find challenging to answer correctly: $\mbox{ }$<jupyter_code>from jupyterquiz import display_quiz
git="https://raw.githubusercontent.com/jmshea/Foundations-of-Data-Science-with-Python/main/questions/"<jupyter_output><empty_output><jupyter_text>**Balls and Boxes/Urns**A class set of probability problems involves pulling colored balls from an urn. I have found that many students are not familiar with the  word *urn* (which is like a large vase), I will use a box instead. To make the problem interesting, the box must contain more than two balls, and the balls must be of at least two different colors. Below I ask some questions about a box containing three balls, of which two are white and one is black.<jupyter_code>display_quiz(git+'ch5-intro.json')<jupyter_output><empty_output><jupyter_text>If you are surprised or confused by the answers, don't worry. That is normal, and even after we solve these in detail, it may still take you some time to build intuition and deeper understanding of these problems. **The Monty Hall Problem**Some readers may be familiar with this problem. However, even if you are familiar with the problem, you may still not understand the mathematics behind solving it.  This problem became famous when it appeared in the "Ask Marilyn" column of *Parade* magazine, which was distributed with many Sunday newspapers. In this column, <NAME> answered tricky questions, and she provided an answer to this problem that provoked a lot of surprise and correspondence. The problem is based on an old TV game show called *Let's Make a Deal*, which was hosted by Monty Hall. (The problem setup varies somewhat from how the actual TV game worked.)  Here is a slightly paraphrased version of the problem from Parade magazine:You are on a game show, and you're given the choice of three doors:* Behind one door is a car* Behind the other doors are goatsYou pick a door, and the host, who knows what's behind the doors, opens another door, which he knows has a goat.The host then offers you the option to switch doors. Does it matter if you switch? If switching changes your probability of getting the prize, what is the new probability?<jupyter_code>display_quiz(git+'ch5-monty-hall.json')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.04505208333333333, 'fraction_numerical': 0.0005208333333333333, 'mean_word_length': 5.225283630470016, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '606798', 'license': 'FSFAP', 'n_tokens_mistral': 891, 'n_tokens_neox': 852, 'n_words': 566, 'path': '06-conditional-prob/intro.ipynb', 'repo_name': 'jmshea/intro-data-science-for-engineers', 'size': '3852'}