News for hackers. Stuff that matters.
Re:A confusing probability question: Red and Green Balls in ... by sxp on Tuesday January 30, 2024 @08:48PM (#39198696)
The mathematical term for this is a "Laplacian urn" and the probability is governed by https://en.wikipedia.org/wiki/Rule_of_succession

In this specific case, P(redOnKthSample) = (numberOfRedSamples + 1) / (totalNumberOfSamples + 2) = (1+1)/(1+2) = 66% red.

On the second draw, if the ball is green, then you get P(redOnThirdSample) = (1 + 1) / ( 2 + 2) = 50%

Re:A confusing probability question: Red and Green Balls in ... by andreimatei1 on Tuesday January 30, 2024 @11:16PM (#39199852)
This answer should go to the top.
Re:A confusing probability question: Red and Green Balls in ... by da39a3ee on Tuesday January 30, 2024 @11:48PM (#39200064)
Except it doesn’t give much intuition for why?
Re:A confusing probability question: Red and Green Balls in ... by feoren on Wednesday January 31, 2024 @01:28AM (#39200667)
I find it hard to remember a ton of different rules, so I just count configurations, and I'm right on these problems basically every time. You count configurations by enumerating all possible combinations of unknowns, then "score" them by likelihood. The configuration's probability is its score divided by the total score. Then take the weighted sum of your test value, with the weights being the configuration probabilities.

There are 101 configurations (the different values of N). We know our first ball was red. So N == 0 has a score of 0 (it's impossible since we found a red), N == 6 has a score of 6 (there are six different ways we could draw a red), N == 100 has a score of 100. The sum of all the scores is 5050, so the probability that N == 100 is 100/5050 = 1.98%.

The value we're interested in is p(2nd ball == red). In the N == 100 configuration, that's 100%: it contributes 100% * 1.98% to the final "score". In the N == 6 configuration, that's 5/99 (we already drew one red), so it contributes 5/99 * 6/5050 to the final score. Add up the final scores and you get 66.67%.

As long as you can feasibly enumerate all possible configurations and score them accurately, this approach basically never fails.