Compute expected value of simple gambling games
J.P. MorganData Scientist · Technical ScreenLast updated
This problem tests your understanding of expected value, probability distributions, and the mechanics of independent trials in simple gambling games.
The Gambling Gauntlet
As a data scientist at J.P. Morgan, you are tasked with modeling two specific gambling scenarios to determine their risk profile. Please solve the following two independent sub-problems.
Part 1: The Weighted Die
You are playing a game with a single six-sided die. You pay an entry fee $F$ to roll the die once. If the result is a 6, you win $20. If the result is anything else, you win $0. What is the maximum entry fee $F$ you should be willing to pay if you want the game to have a non-negative expected profit? Provide the formula and the final numerical value.
Part 2: Alternating Coin Tosses
You and an opponent take turns flipping a fair, two-sided coin. You go first. The first person to flip a "Heads" wins the game.
- Calculate the probability that you win on your first turn.
- Calculate the probability that you win on your second turn (i.e., you get Tails, opponent gets Tails, then you get Heads).
- What is the total probability that you win the game?
Requirements
- Provide the logic and the calculations for each part.
- Use
Pythonif necessary to define a functioncalculate_expected_value(p_win, win_amount)orcalculate_total_win_probability(n_turns)to generalize your findings.
Example
If a game gives you a 1/2 chance to win $10 and a 1/2 chance to win $0, the expected value is (0.5 * 10) + (0.5 * 0) = 5. Your entry fee should be at most $5.
Hints
Hint 1
For Part 1, the expected value is the sum of (probability of outcome * value of outcome) for all possible outcomes.
Hint 2
For Part 2, express your probability as an infinite geometric series: P(win) = P(1st turn) + P(3rd turn) + P(5th turn) + ...
Hint 3
Recall that the sum of an infinite geometric series with first term 'a' and common ratio 'r' is 'a / (1 - r)' where |r| < 1.
Follow-up questions
- How does the maximum entry fee in Part 1 change if the die is loaded such that a 6 appears with 25% probability?
- If the game in Part 2 allows for an infinite number of turns, does the game ever end with a draw? Why or why not?
- How would you simulate the coin toss game in Python to verify your theoretical probability using a Monte Carlo approach?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.