Andy and Beth are playing a game worth $100. They take turns flipping a penny. The first person to get 10 heads will win. But they just realized that they have to be in math class right away and are forced to stop the game. Andy had four heads and Beth had seven heads. How should they divide the pot? # ❔❔❔❔❔❔❔❔❔❔❔❔❔❔❔❔❔❔❔❔❔

## These are the questions I had trying to solve that question:

What is this question asking exactly? Why is it worded this way? What distribution/equation should we be using to solve this? Why don’t they just finish the game? Why don’t they just scratch the last game and play again from the start? Did they both throw in $50 to start? Does the loser simply pay up? Why does the fact that they stopped have to be tied to the splitting of the money? # I will go over the answer provided by the book, why I think this question is fundamentally useless, and a couple variations of this question that I hope will elucidate the intended material.

### The answer provided by the book:

### I will spend a moment trying to steel-man the author’s reasoning:

Andy needs 6 more heads to win, and Beth needs 3 more heads to win. The game will end when one of them gets the required number of heads. Therefore, the maximum number of flips that could decide the game is 6 + 3 − 1 = 8. The author looks at the probability of Andy getting his 6 heads within the next 6, 7, or 8 flips. This is because if the game is settled in exactly 8 flips, Andy could win by getting his 6th head on the 6th, 7th, or 8th flip. If he gets his 6th head on the 6th flip, Beth cannot win anymore because she would only be able to get 2 more heads in the 2 remaining flips, which would give her a total of 9, not 10.

This calculation takes into account all possible ways Andy could win in 6, 7, or 8 flips and sums them to get his total probability of winning.

ans = pnbinom(8-6, 6, 0.5)

ans

[1] 0.1445313

The author's solution is based on calculating the probability of Andy winning by considering all the sequences of coin flips where he gets his required number of heads within the next 8 flips. This calculation is done using the negative binomial distribution.

# Now, my thoughts:

The question does not specify how the game would continue. For example, who would flip first once the game resumes? If Andy flips first, he has a slightly better chance than if Beth flips first because he has the opportunity to increase his head count before Beth does.

The question implies a binary outcome (win/lose), but the game has been interrupted in a non-terminal state. The solution has to assume that the game's outcome can be fairly represented by a probabilistic division of the pot, which in real-life situations WILL be contested by the players.

The concept of "fairness" in dividing the pot is subjective and can vary greatly between individuals. Some might argue that the current score should have a greater impact on the division, while others might prefer a solution based on the probability of each outcome.

### Given that this problem falls under the negative binomial section, the author is assuming that students will recognize that the number of additional flips needed for Andy or Beth to win follows a negative binomial distribution.

# Let’s change everything about this question.

# Here are 4 alternative questions that I hope will help you understand the given concepts in an easily digestible manner. Read one or two, or none, this is up to you. I simply want to give you the alternatives to learn from.

### Negative Binomial Distribution - The Lost Treasure

An archaeologist is searching for a lost treasure. She must pass through a series of ancient traps, each with a 1/3 chance of activation per attempt. The treasure is secured after successfully bypassing 5 traps without activating any. However, the archaeologist can only make 15 attempts before the cave collapses. (a) What is the probability that the archaeologist secures the treasure exactly on her 10th attempt? (b) What is the probability that she makes it out with the treasure without causing a collapse? (c) If she does trigger a trap, she has to restart from the first trap again. What is the probability distribution of the number of times she triggers a trap before escaping with the treasure?" Right, so we got this archaeologist, and each trap has a 1/3 chance of activation. She needs to get past 5 without setting any off. Classic negative binomial stuff. But we'll run this in R to simulate it and give a clear picture.

For part (a), we want to know the probability that our archaeologist gets through on exactly the 10th attempt. This is the probability of 4 successful deactivations (because the 5th success is on the 10th attempt) in the first 9 attempts, followed by a success on the 10th.

In R, we'd use the dnbinom function to get this probability, setting the number of successes to 4 and the number of trials to 9, with a success probability of 2/3 each time (since a 1/3 chance of activation means a 2/3 chance of safe passage).

For part (b), the archaeologist has 15 attempts to bypass 5 traps. We need to sum the probabilities of securing the treasure on the 5th, 6th, ..., 15th attempt.

And for part (c), this one's tricky. Every time a trap is triggered, it's like a reset. We want the distribution of the number of resets before she makes it through all 5 traps. This is a bit like a meta-negative binomial problem, but we can simulate it by tracking resets across many simulations.

(a) Probability of securing the treasure on exactly the 10th attempt:

p_safe <- 2/3

r_successes <- 5

prob_exactly_10th_attempt <- dnbinom(

r_successes - 1,

size = r_successes - 1,

prob = p_safe

)

(b) Probability of securing the treasure within 15 attempts:

max_fail_before_success <- 15 - r_successes

prob_within_15 <- pnbinom(

max_failures_before_success,

size = r_successes,

prob = p_safe

)

(c) Probability distribution of the number of times the archaeologist triggers a trap before escaping with the treasure:

num_simulations <- 100000

r_successes <- 5

p_activation <- 1/3

p_safe <- 1 - p_activation

max_failures_before_success <- 15 - r_successes

triggers_before_success <- numeric(num_simulations)

for (i in 1:num_simulations) {

num_triggers <- 0

num_successes <- 0

while (num_successes < r_successes && num_triggers <= max_failures_before_success) {

if (runif(1) <= p_activation) {

num_triggers <- num_triggers + 1

num_successes <- 0

} else {

num_successes <- num_successes + 1

}

}

triggers_before_success[i] <- num_triggers

}

trigger_distribution <- table(triggers_before_success) / num_simulations

Distribution: [13.3%, 11.55%, 9.93%, 8.52%, 7.21%, 6.51%, 5.74%, 4.89%, 4.29%, 3.75%, 3.07%] for 0 to 10 triggers respectively. ### Hypergeometric Distribution - Alien Invasion

Earth is under attack by aliens with 20 spacecraft. A squadron of pilots is sent out to confront them, and each pilot has a 1/5 chance of successfully bringing down an alien ship. If Earth's command sends out 10 pilots in a desperate first wave, (a) what is the probability that exactly 3 alien ships will be taken down? (b) how does this probability change if the pilots are so skilled that each has a 1/3 chance of success? In this scenario, Earth is under siege, and we're sending out a squadron to deal with these extraterrestrial invaders. The problem at hand deals with the hypergeometric distribution because we're sampling without replacement from a finite population of alien ships.

Now, each pilot has a 1/5 chance of success. That means out of 20 ships, if we think of this in terms of a hypergeometric distribution, we're looking at a population of 20, with a 'success' population of 20/5, which is 4 ships that can be potentially taken down by each pilot.

For part (a), we want to find the probability that exactly 3 ships are taken down by our 10 brave pilots. The hypergeometric distribution can model this situation. We'll calculate this using the dhyper function in R, which requires the number of successes in the sample (3), the number of successes in the population (4), the size of the population minus the number of successes (16), and the sample size (10).

And for part (b), when our pilots are more skilled with a 1/3 chance of success, that changes our success population to 20/3, which isn't a whole number. So we'll round appropriately and recalculate.

### Part (a)

Number of successes in the sample (k): 3 Number of successes in the population (m): 4 (since each pilot has a 1/5 chance) # Hypergeometric Distribution - Alien Invasion Part (a)

N <- 20 # Total number of alien ships

n <- 10 # Number of pilots

m <- N / 5 # Number of ships that can be taken down by each pilot (successes in the population)

k <- 3 # Desired number of successes in the sample

# Probability of exactly 3 ships being taken down

prob_exactly_3 <- dhyper(k, m, N - m, n)

prob_exactly_3

[1] 0.247678

### Part (b)

Adjust the number of successes in the population (m) for the increased pilot skill. # Hypergeometric Distribution - Alien Invasion Part (b)

# Now each pilot has a 1/3 chance of success

m <- round(N / 3) # Adjust the number of successes in the population

# Probability of exactly 3 ships being taken down with more skilled pilots

prob_exactly_3_skilled <- dhyper(k, m, N - m, n)

prob_exactly_3_skilled

[1] 0.3250774

### Multinomial Distribution - The Alchemist's Experiment

An alchemist is attempting to transmute lead into gold, silver, or diamond using a mystical process. Each attempt results in gold with a probability of 0.2, silver with a probability of 0.3, diamond with a probability of 0.1, or failure (still lead) with a probability of 0.4. If the alchemist makes 12 attempts, (a) what is the probability that he ends up with an exact distribution of 4 gold, 3 silver, 2 diamonds, and 3 failures? Our alchemist is essentially running multinomial trials, where each trial can lead to one of four different outcomes. It's a bit like throwing a four-sided die where each side has a different likelihood of landing face up.

Right, so we've got these probabilities: 0.2 for gold, 0.3 for silver, 0.1 for diamond, and 0.4 for a failure. We want to use the dmultinom function in R to figure out the probability of getting a specific combination of outcomes after 12 attempts.

We want the probability for 4 gold, 3 silver, 2 diamonds, and 3 failures. So, we plug these numbers into our multinomial probability mass function.

### Answer:

Desired outcome: 4 gold, 3 silver, 2 diamonds, 3 failures

probabilities <- c(0.2, 0.3, 0.1, 0.4) # probabilities for gold, silver, diamond, failure

outcomes <- c(4, 3, 2, 3) # desired outcomes for gold, silver, diamond, failure

# Probability of the exact distribution of outcomes

prob_exact_distribution <- dmultinom(outcomes, prob = probabilities)

prob_exact_distribution

[1] 0.007664026

### Geometric Distribution - The Hacker's Dilemma

A hacker is trying to bypass a security system that locks after 3 consecutive failed login attempts. The hacker has a 30% chance of guessing the correct password on any given attempt. To avoid the lock, the hacker disconnects after two failed attempts. What is the probability that the hacker will successfully guess the password before the third disconnection? So we have a hacker with a certain strategy to bypass a security system. Each block of attempts is essentially a mini geometric trial.

The hacker has a 30% chance on each individual attempt, but we're looking at blocks of attempts because of the disconnection strategy. The key here is to calculate the probability of success within one block of two attempts.

The probability of success on the first attempt is 30%. But if that fails, there's another shot with the same probability. It's not quite as simple as adding them together, though, because the second attempt only happens if the first one fails.

So we calculate the probability of success within one block as the chance they succeed on the first attempt, plus the chance they fail the first but succeed on the second. That's 0.3 + ( 0.7 × 0.3 ).

And since the hacker disconnects after two failed attempts, each block is independent of the others. They get three of these blocks before the third disconnection. We can calculate the probability of at least one success in three blocks using the complement of the probability of failing all three blocks.

The geometric distribution will give us the probability of failing multiple times in a row before the first success. We'll use 1 minus the probability of failing three blocks to get the probability of at least one success.

We're going to use the pgeom function, which gives us the cumulative probability of getting the first success on or before a certain number of trials.

We'll need the complement of failing three blocks, so that's 1 - pgeom(2, prob_success_in_one_block), where prob_success_in_one_block is the probability we calculated for success within a block.

# Parameters

prob_success_on_attempt <- 0.3 # Probability of guessing correctly on any given attempt

prob_failure_on_attempt <- 1 - prob_success_on_attempt

prob_success_in_one_block <- prob_success_on_attempt + (prob_failure_on_attempt * prob_success_on_attempt)

# The probability of getting at least one success in three blocks

prob_at_least_one_success <- 1 - pgeom(2, prob_success_in_one_block)

prob_at_least_one_success

[1] 0.117649