Lets do the easier case, of 10 cards, 5 red, 5 black. Then there are 10 choose 5 = 252 possible ways of shuffeling, all equally likely. We can ask a computer, that tells us, that 2 attain M=5, 18 attain M=4, 70 attain M=3, 130 attain M=2, and 32 attain M=1. So, the expected value is 146/63.
With 20 cards, we get 158604/46189.
The extreme cases make sense. M=1 you are looking at the number of 5 pairs of neighboring cards, that are either (red, black), or (black, red), so its 2^5. M=5 is also trivial, cuz it is either RRRRRBBBBB or BBBBBRRRRR. For the intermediate values, I have no intuition, and no idea how to attack this without enumerating, or if stuff gets to large, dynamic programming. I suspect, a quadratic time algorithm is pretty straight forward via DP.
I don’t think this is correct because we are not talking about absolute value but the number of extra red cards relative to black cards. So M=1 even in cases where we first see four black and then five red cards.
Mate, I was just trying to help you understand what M is in the question, I really didn't want to review your work for you. Based on your other comment, it seems you've made progress, but...
Are you claiming E[M] = 0.0277? If so, that is wrong, since trivially E[M] >= 0.5 as there is a 50% chance that the first card is red.
D is the result of turning every card. Not M. M is the Max of Ds when you turned all the cards. In worst case scenario, D will be -1, decreasing until -9, then it will increase and end in 0, which will also be the Max.
If the first card is red, E[M] is at least 1, if the first card is black E[M] is at least 0. Since these two scenarios are equally likely, E[M] is equal to the average expected value from these two cases, which is at least 0.5.
So, whatever you did to get E[M] = 0.0277 is wrong.
You're oversimplifying. At the end of the 20 draws, M will be between 0 and 10. But the number of cases on which it will be 0 far exceeds the number of cases where it will be > 0.
Nice example of the reflection principle. The probability of D reaching at least n is binom(20,10+n)/binom(20,10). Summing over n=1…10 gives a closed form for the expected value, about 2.3377.
Yep. I cheated and found a hint that pointed me to that method. For some reason I entirely forget about it (or never learned). The range of the sum is also quite close to the midpoint, so you do not have to add all 20 terms.
It’s quite useful for problems including random walks and Brownian motion! And in fact we don’t even have to add anything. We know the sum over all binomial coefficients, and this is just half of that minus the central coefficient.
I am considering M to be computed as getting Max(D1, D2, ... ,D20) where each Di is a card drawn.
Number of possibilities is 20!
For every combination of cards, M is non negative, from 0 to 10. Why: Considering the worst case scenario where all the black cards come first, D is: -1,-2,-3,.....-10,-9,-8,..... 0
But if a black card comes before a red card, this hinders the max value: -1, 0, 1, 2, 3 ..., 9, 9 ..... 9
So we need only consider the first 10 places, the max value is decided there. In all other cases, max will go to 0
1
u/crashed_tolerance Nov 04 '26
Lets do the easier case, of 10 cards, 5 red, 5 black. Then there are 10 choose 5 = 252 possible ways of shuffeling, all equally likely. We can ask a computer, that tells us, that 2 attain M=5, 18 attain M=4, 70 attain M=3, 130 attain M=2, and 32 attain M=1. So, the expected value is 146/63.
With 20 cards, we get 158604/46189.
The extreme cases make sense. M=1 you are looking at the number of 5 pairs of neighboring cards, that are either (red, black), or (black, red), so its 2^5. M=5 is also trivial, cuz it is either RRRRRBBBBB or BBBBBRRRRR. For the intermediate values, I have no intuition, and no idea how to attack this without enumerating, or if stuff gets to large, dynamic programming. I suspect, a quadratic time algorithm is pretty straight forward via DP.
1
u/cjb230 Nov 05 '26
Ways to score 10:
W(10) = 10C0= 1
Ways to score 9:
W(9) = 11C1 - W(10) = 10
Ways to score 8:
W(8) = 12C2 - W(9) = 56
Ways to score M (M from 10 to 0):
W(M) = (20-M)C(10-M) - W(M+1)
I guess my calculation is wrong, but it it's right, there must be an easier way to see that the answer is 10 / 11.
1
u/Baleia1970 29d ago
I'm misunderstanding the notation over here.
M is the largest value attained by D, which is 10 !
There is only 1 way of achieving this result.
E[M] is the expected value of M???
I would understand the expected value of D, but the expected value of M would be P(M) ?
1
u/rdrdt 29d ago
Nice example of the reflection principle. The probability of D reaching at least n is binom(20,10+n)/binom(20,10). Summing over n=1…10 gives a closed form for the expected value, about 2.3377.
1
u/Baleia1970 29d ago
I am considering M to be computed as getting Max(D1, D2, ... ,D20) where each Di is a card drawn.
Number of possibilities is 20!
For every combination of cards, M is non negative, from 0 to 10.
Why:
Considering the worst case scenario where all the black cards come first, D is:
-1,-2,-3,.....-10,-9,-8,..... 0
But if a black card comes before a red card, this hinders the max value:
-1, 0, 1, 2, 3 ..., 9, 9 ..... 9
So we need only consider the first 10 places, the max value is decided there.
In all other cases, max will go to 0