I've got a game that can be described by flipping coins over 7 days. Every day I get a number of coins described by a Poisson distribution. Each coin flips heads with probability $p$, and if I succeed, I get to keep the coin for the next day and flip again. Every Successful coin flip, I get to take a percentage of the reward pot which starts off with $1000. What is my expected reward for playing this game?
For example: On Monday, I receive 2 coins due to the poissson spawn rate. That day I flip the first coin. It comes up tails so I lose it. The second coin is heads. I get my 15% of the pot (so \$150) the first day and get to keep the coin for Tuesday. On Tuesday, I receive 0 coins, but I still have my coin from Monday. I get to flip that coin and it comes up heads again. My payoff this time is 15% of 1000-150=850 so \$127.5. If I receive no more coins, or all my coin tosses are tails for the other 5 days, my total reward is \$150 + \$127.5 = \$177.5
Im trying to solve this piece by piece and verify it with simulations, however, I cant get the two to align. Here's what I've got so far:
Let $\lambda$ be the parameter for the poissson number of coins per day. I would expect to receive a total of $7\lambda$ total coins over the course of a week. Each coin follows a geometric distribution, so it should last on average $1/p$ days. Therefore, I would expect to have a total of $7\lambda/p$ coin flips for the week. This is where my math doesn't align with my simulation. I know my math should be an over estimate since Im ignoring the truncation that happens when a coin spawns on the last day. If I receive a reward from it, it would only be for one day instead of $1/p$ days. However, my simulations give higher values than my math.
For reference, here is my code:
import numpy as np trials = int(1e5) spawn_rate = 0.08147 days = 7 persist = 0.75 toss_count = 0 for _ in xrange(trials): # A vector of 7 days, with each element recording the number of coins spawned that day coins = np.random.poisson(spawn_rate, days) # Convert the spawned coins into the number of successful tosses per day tosses_per_day =  * days for idx,num_coins in enumerate(coins): for coin in range(num_coins): # For each coin today, add to the toss count as long as this coin persists offset = 0 while np.random.uniform() < persist: try: # The coin landed heads, so add it to the toss count for this day tosses_per_day[idx + offset] += 1 except IndexError: # Do not count when a coin could continue past 7 days break offset += 1 toss_count += np.sum(tosses_per_day) # return the average heads per week print toss_count / float(trials)
Here is another program that produces the same results as above. This leads me to believe my original expression of $7\lambda/p$ is either wrong or the assumption of extending past a week does not hold well enough for the time frame.
import numpy as np persist = 0.75 spawn_rate = 0.08147 def day(yesterday_coins, heads_to_date, total_days): if total_days <= 0: return heads_to_date else: today_coins = yesterday_coins + np.random.poisson(spawn_rate) tomorrow_coins = today_coins heads = 0; for _ in xrange(today_coins): if np.random.uniform() < persist: heads += 1 else: tomorrow_coins -= 1 return day(tomorrow_coins, heads_to_date + heads, total_days -1) trials = int(1e5) count = 0 for _ in xrange(trials): count += day(0,0,7) print count / float(trials)
Keep in mind that Im looking for a mathematical expression for the expected value rather than a program to compute it for me.