January 15th, 2021 at 10:55:21 AM
permalink
I have a rather complex game, whose expected value I need to find. Given is a binary random value with probability for success p (lets say an unfair coin with probability of landing heads p and tails 1-p, p<<0,5) The rules of the games are the following: you start by betting 1 euro, a multiplier = 1 and 15 tosses. Each time you land heads (less likely option) you receive 15 more tosses (added to the remaining one you have) and your multiplier increases by 1. Landing tails doesn't give you anything, you've just lost one toss. Your multiplier can grow up to 5, and each time you land a head after achieving a multiplier of 5 adds new 15 tosses, but does not increase the multiplier further. I am seeking for the expected multiplier of the game.
I started by building a Markov Chain table A[i,j] for the probability of spin j to have multiplier i: A[1,1] = 1, A[1,2] = 1-p, A[2,2] = p, A[1,3] = (1-p)*(1-p0), etc... We have 15 initial spins then each A[i, 15+i] = 0. But I am still stuck of deriving the Avg MP from the table. Any help will be much appreciated!
Thanks!
I started by building a Markov Chain table A[i,j] for the probability of spin j to have multiplier i: A[1,1] = 1, A[1,2] = 1-p, A[2,2] = p, A[1,3] = (1-p)*(1-p0), etc... We have 15 initial spins then each A[i, 15+i] = 0. But I am still stuck of deriving the Avg MP from the table. Any help will be much appreciated!
Thanks!
January 15th, 2021 at 1:23:22 PM
permalink
If I am reading the problem correctly, there is an easier way to solve this than with a Markov chain.
The final multiplier is:
1, if none of the first 15 tosses are heads;
2, if one of the first 15 tosses is a head but none of the next 15 are;
3, if two of the first 30 tosses (including at least one of the first 15) are heads but none of the next 15 are;
4, if three of the first 45 tosses (including at least one of the first 15 and at least two of the first 30) are heads but none of the next 15 are;
5, in all other cases.
Let p be the probability of heads, and q (i.e. 1 - p) the probability of tails.
Case 1 has a probability of q^15
Case 2 has a probability of 15 p q^29 (since there are 15 ways to have 1 head in the first 15 tosses)
For Case 3, there are C(15,2) = 105 ways to have both heads in the first 15, and 15 x 15 = 225 to have one in the first 15 and one in the second 15, for a total of 330.
Case 3 has a probability of 330 p^2 q^43.
For Case 4, there are C(15,3) = 455 ways to have three heads in the first 15, C(15,2) x 15 = 1575 ways to have two heads in one group of 15 and one in another, and 15^3 = 3375 ways to have one in each group.
There are three acceptable ways to have two in one group and one in another: (2,1,0), (2,0,1), and (1,2,0). Of the other three, (0,1,2) and (0,2,1) do not have the required "at least one head in the first 15," and (1,0,2) do not have the required "at least two heads in the first 30." Therefore, the total number of Case 4 ways = 455 + 1575 x 3 + 3375 = 8555.
Case 4 has a probability of 8555 p^3 q^57.
Case 5 has a probability of (1 - Case 1 - Case 2 - Case 3 - Case 4) = 1 - q^15 - 15 p q^29 - 330 p^2 q^43 - 8555 p^3 q^57.
The expected multiplier is the sum of:
1 x q^15
2 x 15 p q^29
3 x 330 p^2 q^43
4 x 8555 p^3 q^57
5 x (1 - q^15 - 15 p q^29 - 330 p^2 q^43 - 8555 p^3 q^57)
This is 5 - 4 (q^15) - 3 (15 p q^29) - 2 (330 p^2 q^43) - (8555 p^3 q^57)
= 5 - 4 (1-p)^15 - 45 p (1-p)^29 - 660 p^2 (1-p)^43 - 8555 p^3 (1-p)^57.
This appears to match what I get in simulations for various values of p.
The final multiplier is:
1, if none of the first 15 tosses are heads;
2, if one of the first 15 tosses is a head but none of the next 15 are;
3, if two of the first 30 tosses (including at least one of the first 15) are heads but none of the next 15 are;
4, if three of the first 45 tosses (including at least one of the first 15 and at least two of the first 30) are heads but none of the next 15 are;
5, in all other cases.
Let p be the probability of heads, and q (i.e. 1 - p) the probability of tails.
Case 1 has a probability of q^15
Case 2 has a probability of 15 p q^29 (since there are 15 ways to have 1 head in the first 15 tosses)
For Case 3, there are C(15,2) = 105 ways to have both heads in the first 15, and 15 x 15 = 225 to have one in the first 15 and one in the second 15, for a total of 330.
Case 3 has a probability of 330 p^2 q^43.
For Case 4, there are C(15,3) = 455 ways to have three heads in the first 15, C(15,2) x 15 = 1575 ways to have two heads in one group of 15 and one in another, and 15^3 = 3375 ways to have one in each group.
There are three acceptable ways to have two in one group and one in another: (2,1,0), (2,0,1), and (1,2,0). Of the other three, (0,1,2) and (0,2,1) do not have the required "at least one head in the first 15," and (1,0,2) do not have the required "at least two heads in the first 30." Therefore, the total number of Case 4 ways = 455 + 1575 x 3 + 3375 = 8555.
Case 4 has a probability of 8555 p^3 q^57.
Case 5 has a probability of (1 - Case 1 - Case 2 - Case 3 - Case 4) = 1 - q^15 - 15 p q^29 - 330 p^2 q^43 - 8555 p^3 q^57.
The expected multiplier is the sum of:
1 x q^15
2 x 15 p q^29
3 x 330 p^2 q^43
4 x 8555 p^3 q^57
5 x (1 - q^15 - 15 p q^29 - 330 p^2 q^43 - 8555 p^3 q^57)
This is 5 - 4 (q^15) - 3 (15 p q^29) - 2 (330 p^2 q^43) - (8555 p^3 q^57)
= 5 - 4 (1-p)^15 - 45 p (1-p)^29 - 660 p^2 (1-p)^43 - 8555 p^3 (1-p)^57.
This appears to match what I get in simulations for various values of p.
Last edited by: ThatDonGuy on Jan 15, 2021
January 16th, 2021 at 7:42:43 AM
permalink
Hey, ThatDonGuy,
Thanks for the very detailed answer. It seems very reasonable what you wrote, but maybe I didn't explain clearly what I'm seeking for. I am in search of he Avg Mp per spin, and as far as I understand your approach, with it, we get the chances that the last mp will be 1, 2, 3, 4 or 5. Let me explain myself more clearly, in case 2 for example, depending on which is the toss getting heads we have these outcomes:
1 spin w MP 1 and 29 w. MP 2,
2 spins w. MP 1 and 28 w. MP 2, etc ..
Then calculating the Average multiplier for this case would be ((1*1+2*29)/30 + (1*2+2*28)/30 + ... + (1*15+2*15)/30)/15 = 1.73333 (instead of 2) and so on.
I know how to find out the average amount of tosses one will have, it's 15/(1-15p), coming from the geometric series 15(1+15p+(15p)^2 + ...) but I don't know how to calculate the average MP of each toss, that's why I started via MC.
Again thanks for your answer and I'd deffinitely appreciate further help!
Thanks for the very detailed answer. It seems very reasonable what you wrote, but maybe I didn't explain clearly what I'm seeking for. I am in search of he Avg Mp per spin, and as far as I understand your approach, with it, we get the chances that the last mp will be 1, 2, 3, 4 or 5. Let me explain myself more clearly, in case 2 for example, depending on which is the toss getting heads we have these outcomes:
1 spin w MP 1 and 29 w. MP 2,
2 spins w. MP 1 and 28 w. MP 2, etc ..
Then calculating the Average multiplier for this case would be ((1*1+2*29)/30 + (1*2+2*28)/30 + ... + (1*15+2*15)/30)/15 = 1.73333 (instead of 2) and so on.
I know how to find out the average amount of tosses one will have, it's 15/(1-15p), coming from the geometric series 15(1+15p+(15p)^2 + ...) but I don't know how to calculate the average MP of each toss, that's why I started via MC.
Again thanks for your answer and I'd deffinitely appreciate further help!
January 28th, 2021 at 4:27:10 PM
permalink
I wrote some simple python code to simulate this. It's obviously highly dependent on the probability of the coin flip, but average MP seems to converge pretty sharply to 2.4 when prob(heads) = 5%. You might be able to infer the rest if you try different values and graph them:
#!/usr/bin/python
import random
total_iterations = 10000
def one_iteration():
heads_probability = 0.05;
multiplier = 1;
tosses = 15
while tosses:
tosses -= 1
# coin flipped heads
if random.uniform(0,1) < heads_probability:
tosses += 15
if(multiplier < 5):
multiplier += 1
return multiplier;
def main():
mult_sum = 0.0
i=0
while(i<total_iterations):
mult_sum += one_iteration();
i+=1
multiplier = mult_sum / total_iterations
print ("avg mult:" + str(multiplier))
main()
January 28th, 2021 at 6:11:38 PM
permalink
Quote: spinswizardAgain thanks for your answer and I'd deffinitely appreciate further help!
Since you have the expected number of tosses, all you really need to calculate is the expected sum of all of the multipliers. The problem is, you have two variables to track - the number of spins remaining, and the current multiplier
Let M(a,b) be the sum of the multipliers of the remaining spins with a spins remaining and the current multiplier b.
If b < 5, then M(a,b) = b + p M(a+15, b+1) + (1-p) M(a-1, b)
M(a,5) = 5 + p M(a+15, 5) + (1-p) M(a-1, 5)
Note that M(0,b) = 0 for all b; you are trying to determine M(15,1).
Once you do that, divide by the expected number of spins.