<jupyter_start><jupyter_text>Probability and Expected ValueYou might have already learned a lot about probability. Answer these questions, and look up any relevant information (or ask) as you go: 1. You roll a fair six-sided die and a fair 20-sided die. What is the probability that:    a. The dice match each other    b. You roll at least one 6    c. You did not roll any multiples of 3    d. The sum of the numbers rolled is even 2. If you roll the six-sided die 120 times, how many times do you expect to see the number 5? Write some python code to simulate this, and verify your answer. 3. What happens if you roll the die 1,200 times? 12,000? 120,000? 4. Your friend wants to make a bet with you: You flip a fair coin. If it lands on heads, you get a cup of coffee, but if it lands on tails, you lose a cup of coffee. The coin is flipped 2000 times. How many cups of coffee do you expect to have at the end?<jupyter_code>import random
coffee = 0
for _ in range(100000):
  roll = random.randint(0,1)
  coffee += 1 if roll == 0 else -1 # ternary operator; A if condition else B
coffee<jupyter_output><empty_output><jupyter_text>5. A researcher is conducting a study on the proportion of adults in the US who are in favor of mandatory covid vaccinations. The researcher comments that because of the law of large numbers, the sampling method doesn't matter as long as the sample size is large enough. Explain why this claim is incorrect. 6. Your favorite coffee shop has a promotion where each customer who enters gets to spin a wheel. They have a 5% chance of winning one free coffee and 3% chance of winning two free coffees. The rest of the wheel is blank.    a. What is the probability of not winning at least one coffee?    b. On average, how many coffees would a customer expect to win upon spinning the wheel? Why could this be useful information? $Expected Value = \sum{E * P(E)}$ $Expected Value = \sum{Event * P(Event)}$<jupyter_code>0*.92 + 1 * .05 + 2 * .03<jupyter_output><empty_output><jupyter_text>7. A player stumbles upon a rare chest in a video game and knows that a random amount of gold will be generated upon opening it. This is the probability distribution:|Probability|Gold||--------|----||1%       |1000||10%      |500 ||50%      |100 ||39%      |80  |  What's the expected amount of gold this player will receive?<jupyter_code>e = [1000,500,100,80]
p_e = [.01, .1, .5, .39]
expected_value = sum(e[i] * p_e[i] for i in range(len(e)))
expected_value<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07550938873351977, 'fraction_numerical': 0.037554934079105075, 'mean_word_length': 3.862135922330097, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, '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': '405338', 'license': 'MIT', 'n_tokens_mistral': 786, 'n_tokens_neox': 707, 'n_words': 399, 'path': 'art of data/topics/probability/probability_expected_value.ipynb', 'repo_name': 'lee-edu/materials', 'size': '2503'}