32 ms·
A confusing probability question: Red and green balls in an urn
A Twitter post made the rounds yesterday asking the following question in the form of a poll (https://twitter.com/littmath/status/1751648838501224790 https://twitter.com/littmath/status/1751648838501224790):
Daniel Litt
@littmath
You are given an urn containing 100 balls; n of them are red, and 100-n are green, where n is chosen uniformly at random in [0, 100]. You take a random ball out of the urn—it’s red—and discard it. The next ball you pick (out of the 99 remaining) is:
More likely to be red
22.6%
More likely to be green
37.1%
Equally likely
20.9%
Don’t know/see results
19.5%
I thought it was interesting (but not surprising) that so many people got this wrong. Basically, Bayesian thinking is really foreign to people. It's essentially similar to the famous Monty Hall problem, where the first bit of information tells you something about the world. In any case, I thought it might be illuminating to give a complete demonstration, using both exact calculations AND simulation, of the "wrong" and "right" approach, which you can see at the Colab link above.
- deleted 3y ago[deleted]
- Terr_ 3y agoTo try to put it into words: We don't actually know the mix-rate of what's in the urn. It's possible we just pulled the only red ball and all the others are green... However the fact that our first n=1 sample happened to be red (and not something else) gives a small (and varying) amount of confidence towards red-heavier mixes rather than the red-scarce ones. We can use that to figure out which mixes are slightly more-likely to be in there (based on our tiny amount of data after assuming they begin equally-likely) and then for each of those determine "if it's mix X, then what are the odds of our next draw", and combine the two layers of probability. In this case, the bias towards presuming the mix is fundamentally reddish outweighs the presumption of "removing one red makes the greens the majority."
- eigenvalue 3y agoYes, that's exactly right. Paraphrasing what another poster wrote about this on Twitter: "You would rather go fishing in a lake where you just saw someone else catch a fish." Also, the logic continues as you draw more balls from the urn. If the second ball is ALSO red, then you have even more evidence suggesting that N was selected in such a way as to make red the overwhelmingly more likely choice. Thus the chance of the third ball being red is even higher than the 66% probability in the second draw.
- Terr_ 3y agoTo extend the fishing metaphor, the premise of ~100 balls is also important: If each lake could only sustain one (good) fish, you would actively avoid anywhere someone had already caught one from.
- user_7832 3y agoI guess the counterpoint to this is as the number of balls goes from 100 to infinite, it becomes increasingly harder to predict, correct?
- cornel_io 3y agoNo, the higher the count goes the closer it becomes to the single removed ball not mattering at all, so the only thing that matters is the information you got about which urn you're selecting from.
- eigenvalue 3y agoAccording to the original poster on Twitter: "One cool thing is that this probability doesn’t change if you replace 100 in the statement of the problem with some other number (as long as it’s at least 2), as these arguments show." Source: https://x.com/littmath/status/1752167731682492522?s=46 https://x.com/littmath/status/1752167731682492522?s=46
- pvg 3y agoThat's "what's the probability you've caught the world's meanest fish".
- fractal618 3y agoI agree. This is a beautiful summary of the logic I used
- planede 3y ago> However the fact that our first n=1 sample happened to be red (and not something else) gives a small (and varying) amount of confidence towards red-heavier mixes rather than the red-scarce ones. I wouldn't characterize this as a small amount of confidence, as conditional distribution of the mix-rate after the first sample drastically differs from the prior. Originally each mix-rate has 1/101 probablity. After the sample having a mix with n reds in it has the probablity 2n/(100101).
- orlp 3y agoFollow up question: > You are given an urn containing 100 balls; n of them are red, and 100-n are green, where n is chosen uniformly at random in [0, 100]. You select 99 balls at random and find that they are all red. What is the probability the last ball is red?
- russdill 3y ago50%. With current knowledge N is either 100 or 99 with an equal probability.
- a_cardboard_box 3y agoInitially there is an equal chance that there are 99 or 100 red balls. But if there is a green ball, it is unlikely to be the last picked. So the fact that you saw 99 red balls makes it unlikely there is a green ball.
- addandsubtract 3y agoNo, the chance of it being red is much higher. If there's one green ball in the jar, than all previous draws would've needed to avoid the green one. The chances of that happening are way less than 50%.
- deleted 3y ago[deleted]
- fallingsprings 3y agoThis is a fantastic follow up question. The last ball is overwhelmingly likely to be red, though this is very counterintuitive. The “all-red” urn and the “all-red-but-one” urn were equally likely to be chosen at the start. But the draws have given you a lot of info about which distribution you’ve been drawing from. Were you sampling from the all-red distribution, your draws would be totally unsurprising — you would observe a run of 99 consecutive reds 100% of the time. If you were you sampling from the all-red-but-one distribution, however, you’d only have observed this outcome 1/100 times.
- thsksbd 3y agoOff the top of my head and using my fingers the probability is: 4901:4900 in favor of red. (100*98/2 = 100*49. Plus one in favor of red) If the number of distribution were odd, the odds would be even. Am I right?
- friend_and_foe 3y agoWhere did you get 98 from? Let's try it as a set of 3 balls. You have 3 balls in an urn, random number of red v green, the first one you pull is red, what's the likelihood that the second one you pull is also red?
- thsksbd 3y agoThose are the distributions that perfectly mirror. There is another one that is alone that has an extra ball, 50:49. So I added one to one side instead of 50 and 49 to the other. So 4950:4949. ... is that right? Im pretty sure red is favored, and Im pretty sure if the number of dists were odd the odds would be even. But are the odds right?
- bitshiftfaced 3y agoI'm stuck at the first continue statement. Doesn't that suck up one of your num_trials? This can never happen per the conditions laid out, but then you put num_trials in the denominator when returning the percent of times it was green.
- tqi 3y agoI think this is less about Bayesian thinking and more about misinterpreting the question, as another poster mentions: https://twitter.com/farrwill/status/1751788706355392639 https://twitter.com/farrwill/status/1751788706355392639 ie i think many of the More Likely to be Green people are doing the math of if you pull from an urn with n/100 odds of getting red, your second pull will have odds (n-1)/99, which is less than n/100 for all n except n=100. Which is obviously a different question than should you bet on Green or Red. Which is obviously a different question than "would you bet on the next ball being red or green"
- eigenvalue 3y agoI'd argue that it's not so much a difference of opinion than it is just a reasoning error given the question as stated. That's sort of the whole point of this post-- this is a case where "doing the math" in the expected way gives the wrong answer, because the state of the system is cast in stone (in terms of the ratio of red/green balls in the urn) when you first start out, so it's all about leveraging the information you get from your first choice. I think this sort of reasoning is actually surprisingly useful and widely applicable in everyday life, like in investing or diagnosing the likely cause of a software bug from incomplete information.
- danielmarkbruce 3y agoIt's definitely a poorly worded question. "More likely" is ill-defined. More likely than what? Than the last draw? Than drawing the other color just on this pick?
- posix86 3y agoMore likely than the other option, given the information. Getting an accurate grasp on the information is the whole point of the question.
- danielmarkbruce 3y agoWhy is that the question? Why not "more likely than the last draw" ?
- ggm 3y agoYes, but which door has the goat behind it?
- mitthrowaway2 3y agoUniform n is what drives a lot of the interesting properties here. Other distributions can behave differently. For example if balls were inserted into the urn with their colors determined independently by coin flips, then instead of n being uniform it would be binomial. In that case, observing the color of a previously drawn ball would tell you nothing about the next one.
- danielmarkbruce 3y agoYes.
- eximius 3y agoIs that true? You'd still have evidence that the distribution of balls tilts one way, wouldn't you?
- danielmarkbruce 3y agoI think with a binomial the tilt is perfectly offset by the tilt you get from taking the ball.My math isn't fresh enough to write a nice dense statement showing why. If you change their simulation formula to pull from a binomial instead of uniform... it looks 50/50.
- jncfhnb 3y agoThe probability of flipping a coin and getting heads is the same as flipping ten coins, choosing one at random, and getting heads. Since the probability is the same, you have learned nothing about the distribution of unchecked coins. Since the coins are independently flipped, you can assume that it’s still just a binomial distribution of size n-1 and the same p.
- jncfhnb 3y agoFlip three coins. First one lands heads. Does that mean the rest are more likely to be heads? No.
- 3y ago
- danielmarkbruce 3y agoChange it to drawing from a normal distribution... the answer will change dramatically and get very close to what one would likely consider "common sense", ie that it remains close to 50/50. I think binomial gets it to 50/50. Humans aren't wired for uniform distribution. 100 reds seems crazy unlikely compared to 50/50, yet this trick question makes those equally likely.
- j7ake 3y agoHow would normal distribution change the result? I am imaging a random number generated from truncated normal distribution with mean 50, clipped 0 and 100: the answer will still lean right. How would binomial work? You have 101 urns from which to choose.
- danielmarkbruce 3y agoNormal: it is very close to 50/50. It does still lean, but only just. It's close enough that in practice any guess is fine. Binomial: it is 50/50. The reason these change the situation dramatically is that under normal or binomial, you are waaaay more likely to be in a situation that is close to 50/50 to begin with because they are way more likely to occur. The quirk of this question is that a 0 green 100 red urn is just as likely as a 50-50 red/green urn using a uniform distribution - hence if you get red on the first draw you are much more likely to be in a heavily tilted red urn.
- j7ake 3y agoHow would binomial work here? You’re choosing amongst 101 urns of different proportions. How do you narrow 101 choices into two?
- BeetleB 3y agoIt's as ill posed as the Monty Hall problem. The issue is in what it means for the first ball to picked randomly. Would the question be valid if the first ball was green? If not, then it's equivalent to the standard answer to the Monty Hall problem. Analyze it as if the first ball was not picked randomly (i.e. Monty intentionally picked the wrong door).
- chrismcb 3y agoI'm not sure why you think it is ill posed. The question is, you randomly pick a ball, IF it is red then... So yeah, it is basically the same as "someone else removes a red ball" now randomly select a ball. OR Pick a ball, is the color of the second ball more likely to be the same as the first, different, or equal. That is really the question here. edit: After thinking about it some more, it is NOTHING like handing the bag to someone else and having them remove a red ball. The whole point to the first draw is to draw the ball randomly. I think my second statement is still true. But to your original question, if the first ball isn't red, then the question is invalid (and you can't throw the ball in and choose again)
- BeetleB 3y agoForgive my frequentist bent, but: When in doubt, simulate (with code). Do this N times for a large N, and take the ratio to get a probability estimate. So the question is: How will you code it? You'll find half the people code it one way (to get one answer), and the other half will code it differently to get a different answer. That's because it is ill posed. As an example, I would code it as: Let n be a random number from 1 to 100 (cannot be 0!) We throw away one red ball as we know we picked one. Construct a list of n-1 red balls, and 100 - n green balls. Pick a ball at random. Success if it is red. Repeat this N times where N is large. Take the ratio of successes with N. When I run it, I get 50% How would you simulate it differently? The problems with the code in the submission: If n==0, he continues, but still counts it as a trial (he still divides by num_trials). He should deduct the number of trials every time n==0.
- bagels 3y ago
- anigbrowl 3y agoI think the wording is also biasing the outcome. The next ball is more likely to be green than the previous ball, and a lot of people will regard that posterior probability statement as implicit. If the question had been phrased differently eg, 'what is the most likely color for the next ball selected' I suspect more people would have voted for equal likelihood.
- eigenvalue 3y agoYes, I think you're right about that. Just look at all the disagreement about it right here in this discussion!
- danielmarkbruce 3y agoAnd if you change the distribution, that answer is close to correct.
- chrismcb 3y agoWhat does the previous ball have to do with it? We KNOW the previous ball is red. Then it asks "more likely to be red" It seems pretty obvious that it is saying draw the next ball, which is more likely? Red, green, equal. Why would you think it is comparing the second pick probability to the first pick probability?
- mewpmewp2 3y agoAgreed. The first likelihood of green is 50 percent, and of the first is red then the next ball likelihood of being green is smaller than 50 percent, so the above statement makes no sense.
- bo1024 3y ago"You shoot a basketball for the first time -- you miss. The second time, you are more likely to score." A common phrasing. It doesn't mean that scoring is more likely than missing, it means the second time is more likely than the first was.
- 3y ago
- deleted 3y ago[deleted]
- jncfhnb 3y agoIt’s not Monty Hall. Monty Hall does not open doors randomly. To think about this problem right you need to acknowledge that it could have gone the other way with some probability but it didn’t, and so that tells you something more about the state of things. If monty opens doors randomly, and shows you a goat, you do not benefit from switching. Edit: assuming he doesn’t open your door of course
- drewcoo 3y agoThis is not about Monty Hall or his doors. ROT13: Gur zber erqf, gur zber yvxryl lbhe svefg chyy vf erq. No one is making changes based on your actions, like Monty did.
- jncfhnb 3y agoThat is… what I said
- eigenvalue 3y agoYes, you're right-- I mispoke in that I meant that they were both examples of getting information that should revise your world view, not that they were exact analogues.
- tines 3y agoI think this is easiest to see if you imagine the urn is filled with three balls. You draw one, and it's red. The possibilities are that the urn originally contained: 1. Red, Red, Red 2. Red, Red, Green 3. Red, Green, Green (The Green, Green, Green case is impossible because you drew one Red.) Drawing a Red from urn configuration (1) was a 100% probability; from (2) was a 66% probability, and from (3) was a 33% probability. If these configurations were equally likely, then the probability of Red and Green on the second draw would be the same. However, and this is the crux: we are more likely to be in a configuration which shows us what we have observed with a higher likelihood [1]; so we're more likely in configuration (1) or (2) than (3), and as (3) is the only one that favors Green for the next draw (and only by as much as (1) favors Red), the next ball being Red is more probable. [1] Imagine, for example, that you have 100 coins, and 99 of those coins are biased so that they only show heads once every trillion tosses, while the remaining one coin is fair. If you pick a coin randomly and flip heads, which is more likely: that you got a biased coin to show a one-in-a-trillion event, or that you picked the fair coin?
- danielmarkbruce 3y agoAnd the underlying cause of people's intuition failing them is caused by those configurations being equally likely, which is a quirk of the question.
- bitshiftfaced 3y agoWhy are we excluding red, green, red?
- danielmarkbruce 3y agoYou have just highlighted the actual problem with the question. Uniform distribution.
- tines 3y agoNot really; he's hypothesizing a potential draw order, but what I was listing were the possible contents of the urn before any are drawn. Since the contents of the urn aren't ordered, they form a set, not a list, and shuffling elements doesn't add to the list of possibilities.
- drewcoo 3y agoHaving to understand probability problems like this by writing code is like having to count the dots to multiply. It's functional innumeracy. Not something to be shamed, but something that needs to be fixed. What is 3 x 2? . . . . . . 1, 2, 3, 4, 5, 6 . . . six? Edit: To add to that, check out the Erdos book from the 90s on innumeracy (here's Wikipedia instead of an AMZN affiliate link): https://en.wikipedia.org/wiki/Innumeracy_(book) https://en.wikipedia.org/wiki/Innumeracy_(book)
- eigenvalue 3y agoThe purpose of the code was to make it clearer what is happening here. If someone is confused by the direct calculation, then they can also look at the simulation and maybe things will become clearer. Also, you do need to have some actual insight into the problem to solve it directly with calculations, whereas you just have to model the situation to brute force a simulation and arrive at essentially the same answer (with a lot more compute used, but that's basically free now!).
- svat 3y agoThe book Innumeracy that you linked: why did you call it "the Erdos book"? It is not connected to Erdős in any way, as far as I can tell.
- QasimK 3y agoSuper confusing! Through different reasoning I get different answers: 1. More likely to be red because the urn has a greater chance of having more red balls 2. Equally likely by considering all remaining urn possibilities to be equally likely 3. More likely to be green because obviously there is one less red ball than before I wrote a Python program to simulate the problem. It tells me that the correct answer is (2) - it's equally likely that the next ball is red or green. I wonder if I've made a mistake, or if that's really the real answer! #!/usr/bin/python import random from collections import Counter def experiment(): urn = random.choices(["R", "G"], k=100) if urn.pop() != "R": return return urn.pop() results = (experiment() for i in range(1_000_000)) results = (result for result in results if result is not None) print(Counter(results)) EDIT: I did make a mistake! The above produces a binomial distribution of urns with red/green. As in, the most common urn is one with an equal number of reds and greens, and the least common is all reds or all greens. Whereas they should have equal probability. To actually match the question: #!/usr/bin/python import random from collections import Counter def experiment(): num_red = random.randint(1, 100) num_green = 100 - num_red urn = ["R"] * num_red + ["G"] * num_green random.shuffle(urn) if urn.pop() != "R": return return urn.pop() results = (experiment() for i in range(1_000_000)) results = (result for result in results if result is not None) print(Counter(results)) The answer is indeed (1) More likely to be red.
- sxp 3y agoThe mathematical term for this is a "Laplacian urn" and the probability is governed by https://en.wikipedia.org/wiki/Rule_of_succession 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%
- andreimatei1 3y agoThis answer should go to the top.
- da39a3ee 3y agoExcept it doesn’t give much intuition for why?
- feoren 3y agoI 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.
- chrismcb 3y agoMy first thought on this is, half the time there will be more red balls in the container. IF you draw a red ball first, you are more likely to be in the half that had more red balls. Therefore you are more likely to draw a second red ball. Yes, a small percent of the time you will be in the case that there are more green balls (maybe you got unlucky and pick the 1 red ball!) So my guess is that it isn't a huge percent higher, but it is more likely to be a red ball.
- bagels 3y agoSeems like there's some ambiguity in the problem. "More likely to be red" More likely than what? "The next ball you draw from this urn is more likely to be red than green?"
- zharknado 3y agoThis is much easier to intuit if I imagine 101 urns. One is 0% red, one 1% red, one 2% red, etc. If I choose one urn at random, and then the first ball I pick is red, odds are good I picked a red-heavy urn. I’d be interested to see if the general public answers differently when it is framed more concretely.
- Syzygies 3y agoOne gets Bose-Einstein statistics from the same urn setup: if you draw two marbles from such an urn, the three combinations RR, RG, GG are equally likely. An obvious visual proof: Line up 101 marbles. Choose one to be the divider; to the left is red, to the right is green. Now draw two more marbles. Or just pick three, then decide which one is the divider.
- fractal618 3y agoI would say red because n is probably larger than 50 if the first one picked was red
- maytc 3y agoNever liked the way these problems are worded. `You take a random ball out of the urn—it’s red—and discard it.` How normal people read it: Given this specific instance where you just discarded a red ball from this urn, what's the probability of the next ball? How it expects you to read it: Given infinitely many random samples from the urn. For cases where you get red, remove it, then take a second sample. What's the probability of the next ball, given all the samplings?
- zarzavat 3y agoI would go further and say that the second reading is in fact incorrect interpretation of the problem in the English language. Being a mathematician doesn’t give some special right to gaslight people on their knowledge of English. This problem is in a similar category as badly explained monty hall problems where the statement of the problem is so bad that it ends up changing the answer. For example I have seen the Monty hall problem stated in popular media like this: “There are three doors, behind two are goats and one is a car. You choose a door at random and there’s a goat behind it. You choose another door, but before opening it the host asks if you want to switch your choice. Is it more profitable to switch or to stick or does it have the same chance?” Of course it doesn’t matter. This is actually a good way to trick inattentive mathematicians who pattern match on the problem but don’t actually read it.
- lencastre 3y agoLove this, can we mangle the problem some more? Like, you open one door and it’s a goat, the host then says he will open another door containing the trip to Bali. Do you want to open the other door or stay with the goat you already have?
- feoren 3y agoBoth of those have the same answer. Why would they not?
- bobbylarrybobby 3y agoBut those two readings have the same answer?
- logicallee 3y agoIn these cases it's always good to think of extremes. For example for the Monte Hall problem imagine a million doors and all but one of them are opened, all empty, in any case. Then it's clear you originally had one in a million chances of picking the right door. Two ways to think about this (same conclusion): - Without loss of generality, take the case of just one red ball, rest are green. If you pick the one red ball on your first draw the chances are now 100% that the next ball is green (since there aren't any red ones left) whereas before you had picked the red one you had just a 99% chance of picking a green one. Hence after picking a red ball you are slightly more likely to pick a green ball next. - Another way to think of it, again without loss of generality consider if there was just one green ball and 99 red, then if you pick every one of them in some order there are a hundred different positions the green one could end up as. If you consider the one where it's last, after you have picked all but one (and they were all red), now you have a 100% chance to pick the green ball, even though you started out with 1% chance on the first draw: without loss of generality in the case of drawing until you reach the green ball when it is 1 in 100, each red ball you have drawn so far increases the chance of drawing the green ball next, up to a 100% chance when it is the only one left. Visualizing the chance going from 1% to 100% in this case as you draw more red balls should drive home the point that it becomes more and more likely you'll draw a green one next, in the cases that you've made it that far drawing red ones.)
- Jiro 3y ago>Without loss of generality, take the case of just one red ball, rest are green. If you pick the one red ball on your first draw the chances are now 100% that the next ball is green (since there aren't any red ones left) whereas before you had picked the red one you had just a 99% chance of picking a green one. Your reasoning can conclude that picking a green ball next time is more likely for any specific bag contents. But you can't then conclude that picking a green ball the next time is more likely, period. Picking red the first time gives you information that changes the probability distribution of likely bag contents.
- tzs 3y agoOK, I'm seeing it now. Generalizing, imagine N+1 jars each containing N balls. The jars are numbered 0 through N. The jar numbered k has k red balls and N-k green balls. We have N+1 people, also numbered 0 through N. Person k is holding jar k. We ask each person to draw a ball at random from their jar. If they draw a green ball they take their jar and leave. If they draw a red ball they stay. We expect on average (N+1)/2 people will remain. We now ask them to draw another ball. The expected number of red balls on this second drawing is (N+1)/3. The expected number of green balls on this second drawing is (N+1)/6, half the expected number of red balls. That's because on the first drawing, the more green balls in your jar the more likely you will draw green on the first round and thus take your jar and go home. The second round is biased toward people who have jars with more red balls. Here's the math behind those results. The probability that person k makes it to round 2 is k/N. The expect number that will make it is sum {k=0, N) = (N+1)/2. Once in round 2 the probability they draw red is (k-1)/(N-1). The probability they draw green is (N-k)/(N-1). The probability then that they make it to the second round and then draw red is k/N (k-1)/(N-1). The probability that they make it to the second round and then draw green is k/N (N-k)/(N-1). The expected number of reds we see in the second round is sum {k=1, N} k (k-1) / N / (N-1). The expected number of greens is sum {k=1, N} k (N-k) / N / (N-1). Use the well known formulas 1 + 2 + 3 + ... + M = M (M+1) / 2 and 1^2 + 2^2 + ... + M^2 = M (M+1) (2M+1) / 6 and simplify and you'll get the (N+1)/3 expected red and (N+1)/6 expected green I stated above.
- dmillar 3y agoEarly in my career, when I first started interviewing, I used to ask a version of this to recent grads. It was never a make-or-break question, but I found it to be a great way to a.) see how people approach problem solving and probability and b.) see how they respond when you start asking whys (even if they answered/guessed 1/3). It's something that takes zero code to answer, and the intuition is easy to grok once explained. The other part I particularly enjoyed was the people who initially guessed wrong, but then got to the answer intuitively almost always sent me code proving the answer. For the record, my question was: "Two points are randomly and uniformly selected on a line 0.0 to 1.0. What is the most probable distance between the two points?"
- LatticeAnimal 3y ago> Two points are randomly and uniformly selected on a line 0.0 to 1.0. What is the most probable distance between the two points? Unless I am reading this wrong, I think all values between 0 and 1 have an equal probability (of 0). The probability that a random uniform variable will equal any number between 0 and 1 is zero. It seems to follow that the probability of the difference between two uniform variables equaling any exact value would also be 0. Have I missed something obvious? If zero really is the correct answer, that is pretty tricky.
- dmillar 3y agoYou have two random uniform variables and the distance/difference/change between to finite points. Put another way (and code it up if you want). Select two random uniformly distributed points between 0 and 1. Do this 10_000 times, whats the average distance between the two? This gets to the question of "most probable" vs "expected value". A conversation I always welcomed.
- kilotaras 3y ago> what is the most probable distance between the two points? > even if they answered/guessed 1/3 1/3 is not the most probable distance, it's the expected value. The most probable distance does not exist, but PDF(d) is strictly decreasing for (d>0).
- mondocat 3y agoNot a unique explanation, but thinking about it like this might make it easier to understand the right answer and the wrong answer that was initially intuitive to me. Imagine calculating the odds by choosing the first ball from every permutation of red and green balls. And then do the same by choosing a random ball from each permutation. The odds of getting red on the first pick in either case is 50% - but it's not the same 50%! With an example of three balls, there are 8 permutations. If we take the first ball from each row, 1-4 have a red ball, and so from there, 1 and 2 have a second red ball, making the chance of a second red ball given a first 50%. However, if we take a random ball from each row, we are guaranteed to get a red first in 1, and more likely to get one in 2, 3, and 5 than the others. In those cases, red will be next 67% of the time. (100% for 1, and 50% for 2, 3, and 4.) 1. rrr 2. rrg 3. rgr 4. rgg 5. grr 6. grg 7. ggr 8. ggg Like in the Monty Hall question, knowing that the first ball is red tells us something about the rest of the balls, that most of them are probably red too.
- mondocat 3y agoSince it kept me up, I'll update.. Let's simplify and look at three balls, whose possible permutations are 1. rrr 2. rrg 3. rgr 4. rgg 5. grr 6. grg 7. ggr 8. ggg There are two approaches that are intuitive and wrong, and then the right approach. Specifically it depends which question you're answering. 1. What are the odds when picking two random balls over and over from the same permutation. - You might assume the odds of each ball are completely independent, making the odds of a first red n/100, and then a second red slightly lower at n-1/99. This is what happens when you pick two random balls over and over from the same permutation. 2. What are the odds when picking the first and second balls from a random permutation. - You might assume that if you've selected a red ball first you must be in permutations 1-4, making the odds of a second red ball 50% (permutations 1-2). This is what happens when choosing the first (and second) ball in order from a random permutation. 3. What are the odds when picking a random ball from a random permutation. - This is what we're actually being asked to do. - In this case the odds of picking red first are proportional to the number of reds in the permutation. Specifically, picking red is guaranteed when in permutation 1, and 67% likely when in permutations 2,3, and 5, but only 33% likely when in scenarios 4, 6, and 7, and impossible in scenario 8. While it is equally likely to be in permutations 4 or 5, unlike scenario 2, you're more likely to choose a red ball when in 5 than 4, and in general, you're more likely to pick a red ball first when in a permutation that has more red balls to choose from. And because it does, the second draw is more likely to be red as well. - Like in the Monty Hall problem, the color of the first ball is, while random, unintuitively not arbitrary, but rather an indication that there are more balls of that color to choose from in the urn, which gives you an advantage in knowing what the second draw will be.
- teo_zero 3y agoImagine you have to guess a random number between 0 and 255, i.e. you have to guess 8 bits. You already know that it's less than 128 so the most significant bit is 0. Can you derive any knowledge about whether the second bit is 0 or 1?
- rrobukef 3y agoWatch out. Because your bits are indexed you have a different problem than before. The first red ball does not give you a significant bit. Instead: Make a sample and now you know that it is greater than a random number unknown to you. Can you derive any knowledge about your next sample?
- kilotaras 3y agoIndeed, indexing changing probabilities is very unintuitive for most people. Here's another fun one. There's two coins on the table that you don't see. The only information provided is that a) one of them is tails b) the left one is tails What is the probability of both being tails? It's 1/3 in (a) and 1/2 in (b). The reasoning being: 1. At first both HH, HT, TH and TT are all equaly likely. 2. In case (a) we discard HH as an option, but in case (b) we discard *both* HH and HT.
- teo_zero 3y agoYes, my fault. In fact random numbers between 0 and 255 don't have the property that number-of-set-bits have uniform distribution.
- PeterStuer 3y agoSeems to be fully depending on your interpretation of "more likely". If you take that as "more likely than it was before", then the answer is obviously "more likely to be green". If you take it as "more likely to be green or red this pull", then that answer would depend fully on the unknown distribution and the closest least wrong answer would be "don't know". Backtranslating from the interpretation/answer pairs, if this was on a test I would go with the former interpretation and answer green.
- waldrews 3y agoBut there is no unknown distribution. There is a latent parameter (the n that's uniformly sampled) whose distribution is known; so the distribution of colors for the next draw is well defined. "Depend fully on the unknown distribution" is a statement about the distribution conditioned on that latent parameter; even in that case, the answer isn't "don't know" but "whatever the ratio of remaining balls given that parameter, and the one drawn ball, is." "Don't know" isn't a valid answer in this case; "Don't know" would be valid if we were not told that n has that uniform distribution. Since (unconditionally) red and green are symmetric, and the first draw is 50-50, the 'more likely/less likely' has the same meaning whether you interpret it as 'more/less than 50-50' or 'more/less than before.' This is convenient; if not for this symmetry, the answer would depend on interpretation of the 'more/less likely' language and could be ambiguous. The way the problem is stated, it is not ambiguous because either reading leads to the same result.
- PeterStuer 3y agoLet me try again. In the first interpretation the red ball drawing signals an absence of the n=0 case for the distribution, so we have a very slightly biased shift towards the red side of the potential n's, now in [0-99] vs [0-100] before the draw, so the question becomes does probabilistic gain in red bias distribution outclass the potential increase in green bias (reds now having reduced by 1 in the particular chosen n we are dealing with)? The second interpretation says that given any selected n, the probability of drawing green of the next ball from that urn can only increase or stay the same (in the all red balls urn case) compared to drawing from that urn before. It is the absolute vs relative interpretation of what the 'more' refers to. I'll grant that the inclusion of 'uniform' for n in the question suggests the absolute interpretation as the relative interpretation would be independent of the uniformity of n. The question could have eliminated ambiguity by just asking for the probability of the next ball color, but given the context of a Google recruitment test they might be more interested in how candidates reason under uncertain conditions rather than their dry probability skills.
- drbig 3y agoSeems that the notion of `uniformly` is the key aspect here, i.e. "the sets are ordered" in my intuitive notion. So if the first one you've picked is red, then the only way for the next one to be green is if you started in the set of one red ball + 99 green balls; so you'd have to "pick" one specific set out of 100 possible (set of "all are green" is already impossible at this point), which is why it is very unlikely, and so you should expect the next one to be red. And the more reds in a row you pick, the less likely you are to see a green one.
- keefle 3y agoGreetings Unfortunately my probability skills are quite bad and i easily get confused, could someone explain where my reasoning fails? I assumed since we have a uniform distribution of red to green balls, then the expected value would be 50 red balls. So I assumed I can use this expected distribution to figure out the probability the question asked in an urn where there is 50 red balls and 50 green balls, and we draw one red ball. The ball we draw next is more likely to be green (since we have 49 red balls vs 50 green balls) Is my mistake that I took the expected value of the uniform distribution before the first ball was drawn? And I should think of the expected distribution of the urn given the first ball drawn was red? If so how would I go about that probabilistically? (i.e. how would I calculate Exp [ n given first ball is red ] ) I can see that if the first ball was red, this removes one of the possible values (all balls are green) And I can see how from all possible urns, the more they have red balls, the higher the likelihood the first ball drawn is red. I would assume this will skew the expected value somehow. Is it like ``` expVal = 0 for all possible n (101 possible values): # possibility of first ball being red when we have n red balls * n * probability of n? expVal += (n / 100) \* n \* (1/101) ``` I'm sure the above is wrong, because this will just decrease the expected value where I am expecting an increase but I'm not sure how to model it I would appreciate any pointers/help
- kibibu 3y agoIt's not 50 red and 50 green. There are 100 total balls, but you don't know how many are red or green. The number of reds is drawn from a uniform distribution, meaning the urn is equally likely to contain 1, 10, 55, or 99 red balls.
- jonkho 3y agoThe fact that a red ball was drawn is new information that suggests there is a higher chance (however slight) that there are actually more red balls in the urn than green balls. Therefore the next ball is likely to be red.
- jcl 3y agoYes, it’s a mistake to take the expected value before the ball is drawn, because the drawn ball adds information, disproportionately changing the expected value. Consider an alternate game, where I flip a hidden coin… if it is heads, I let you pick from an urn with 99 red and 1 green; if it is tails, I let you pick from an urn with 1 red and 99 green. The expected number of red is still 50, and the chance of drawing that first red is still 50%. But once that red is drawn, your expectation of what the next draw will be should change significantly.
- pvaldes 3y agoAnswer is impossible to know without knowing n. If there are n=0 red balls probability of having a red ball is 0%. If n=100 red balls is 100% If the idea is to repeat the experiment until reaching a limit the probability of choosing each number must be taken in account and included, and then we could take an average of all possible results.
- simiones 3y agoThere are 9900 possibilities for the state of the urn after the first ball is picked: 1. n = 1, you can pick any of 99 green balls 2. n = 2, you can pick any of 98 green balls and a red ball 3. ... 100. n = 100, you can pick any of 99 remaining red balls If you count the situations in which you will pick a red ball next, you'll see that there are more than the ones where the next ball is green. Intuitively, given that you picked a red ball, you should expect there to be more red balls in the urn. And the effect of having more red balls than green ones outweighs the effect from removing just one ball.
- pvaldes 3y ago> Intuitively, given that you picked a red ball, you should expect there to be more red balls in the urn. This is what a math person would say, I had seen it many times in science, but is not the correct answer. The correct answer would be: "my sample is too small to carry so much information as I'm claiming that it has". Intuitively If I walk on the street and I see a woman, I can't say anything about the proportion of men and women in the area, absolutely nothing, except: "number of women > 0". This is my result. Is dull and not publishable but also the only that I can infer about the population, because is under-sampled. If the experiment is to take a ball from a bag, see its color and think that I can calculate the number of red balls with only this info, my goals are not realistic I need to keep sampling. (not repeating, sampling the same population, doing ten times an experiment that provide tiny amounts of info will not generate new info about the first population from the air. The populations are independent). You need to improve the size of your sample over the same population. Lots of the early ecology models that are flawless from a math point were basically useless when applied to the real life exactly for this.
- quackenstein 3y agoClassical don't think too much, calculate exercise. 1. Probability to pick green after a red for a given n is p = (100-n)/99 2. For all possible n given the first ball was red -> Integral_[0..100] (100-n)/99 * p(n|red) dn 3. So you need p(n|red) which is obviously different from p(n) for instance n=0 is not possible anymore -> p(n=0) = 1/101 != p(n=0|red) = 0 4. Again don't think to much, calc ... p(n|red) = p(red|n)p(n)/p(red) p(n) = 1/101 (1 of 101 possible n, constant due to uniform distribution), p(red)=0.5 (due to symmetry since p(n) is uniform), p(red|n) = n/100 (n of 100 balls are red) -> p(n|red) = n/5050 5. plausibility check -> sum of p(n|red) for all n should be 1 -> (0 + 1 + 2 .. 100) / 5050 = 5050/5050 = 1 6. Hardest part, the integral from step 2. -> wolfram alpha says 0.33 7. It's a don't-think-too-much-calculate result, so don't be too confident )))
- deleted 3y ago[deleted]
- CiaranMcNulty 3y agoHm I'm not sure if it's correct but here's my logic (here on mastodon https://social.ciaranmc.com/@ciaran/111850662374227629 https://social.ciaranmc.com/@ciaran/111850662374227629) There are N-1 red balls out of 99 remaining, so the probability the next ball is red is (N-1/99). The possible values of N are evenly distributed [1...100] (we discount the N=0 case because we drew a red ball) The total probability that the next ball is red is the sum of the individual probabilities divided by cases: P = SUM[1...100](n-1/99) / 100 = SUM[1...100](n-1) / 99 * 100 = SUM[0...99](n) / 99 * 100 = 4950 / 9900 = 5.0 So red or green are equally likely
- 3PS 3y agoYour mistake is here: > The possible values of N are evenly distributed [1...100] (we discount the N=0 case because we drew a red ball) These probabilities over N are not actually even anymore; the fact that you drew a red ball means that higher values of N are more likely.
- jcl 3y agoThere are actually 10,100 equally likely situations: 101 choices of N x 100 choices of ball. When you completely discount the N=0 case, it’s because all choices of ball are green. You similarly need to almost completely discount the N=1 case, because almost all choices of ball in that situation are green, etc.
- Anotheroneagain 3y agoIt seems totally obvious that about 3/4 of "red first" cases happen with red majority urns. I tried to think how so many people could get confused into thinking anything else. I've read the code, and I still don't get it.
- _v7gu 3y agosince everyone is sharing code, why not? I feel this is a simpler way of sharing reasoning anyway. (in k; ! is iota, % is divide and +/ sums up a list) wa:!101 / world amplitudes given we picked red (i.e relative probability) wp:wa%+/wa / convert amplitude to probability np:(wa-1)%99 / probability of next pick being red for each world +/wp*np / sum the conditional probabilities of course, if you wanted to golf this, you'd end up with {2%3}
- dandanua 3y agoP(r2 | r1) = P(r1 ∩ r2) / P(r1) = 2P(r1 ∩ r2) = 2∑P(n ∩ r1 ∩ r2) = 2∑(1/101 * n/100 * (n-1)/99) = 2/3. Just expand conditional probabilities and use the law of total probability. Intuitively, first pick red means the urn is more likely to be filled with red.
- onos 3y agoInterestingly, you get 2/3 no matter how many balls you have, doesn’t have to be 100.
- j7ake 3y agoIn general for N total balls (N>1): Pr(R,R) = 2 / ( (N+1) (N) (N-1) ) * N^3 / 3 The N^3 / 3 is just the integral of N^2 evaluated from 0 to N. As N gets large, then Pr(R,R) approaches (2/3) because the cubic terms in numerator and denominator cancel out. This means that no matter what N is, probability of red,red will always be greater than probability of red,green.
- rasse 3y agoSomewhat related is the "boy or girl paradox" ( https://en.m.wikipedia.org/wiki/Boy_or_girl_paradox https://en.m.wikipedia.org/wiki/Boy_or_girl_paradox ), where the answer to "Mr. Smith has two children. At least one of them is a boy. What is the probability that both children are boys?” may be 2/3 instead of 1/2. The problem is much debated. I was made aware of this paradox by the book Bernoulli's Fallacy by Aubrey Clayton ( https://www.goodreads.com/book/show/55825328-bernoulli-s-fallacy https://www.goodreads.com/book/show/55825328-bernoulli-s-fal... ), which I do recommend as an interesting read.
- layer8 3y agoConsider a 100 x 101 grid (101 rows and 100 columns). Each row is a possible urn (from 0 green balls to 100 green balls). The columns correspond to the 100 balls in each urn. The rows are sorted by ascending number of green balls, and the columns are sorted by red balls first. Reduced to 10 x 11, this would be: RRRRRRRRRR RRRRRRRRRG RRRRRRRRGG RRRRRRRGGG RRRRRRGGGG RRRRRGGGGG RRRRGGGGGG RRRGGGGGGG RRGGGGGGGG RGGGGGGGGG GGGGGGGGGG The rows are parallel universes, each of them equally likely. When you draw the first ball, the universes each split into 100 also equally likely universes, corresponding to which of the 100 balls you drew. So each of the 10100 grid cells represents a possible universe you can find yourself in, each equally likely. When you draw red, you know that you are somewhere in the upper left triangle of Rs, which each R being equally likely. RRRRRRRRRR RRRRRRRRR RRRRRRRR RRRRRRR RRRRRR RRRRR RRRR RRR RR R It’s clear that you are more likely to be in the upper half of that triangle, because it contains more Rs. In fact, because there are 5050 Rs, and the upper 30 rows have 2565 Rs (I’m applying the triangle-number formula n * (n + 1) / 2), you’re more likely to be within the upper 30 rows (urns) than the lower 70 rows (urns), and hence it is clearly more likely that the second ball you draw is again red rather than green. (Though visualizing this further split of universes would require a 3rd dimension.)
- AtNightWeCode 3y agoJust to be clear. Red is the correct answer, right?
- chrissnow2023 3y agoThe key is the initial assumption "n is chosen uniformly at random in [0, 100]". This is rare in real life and few people can really understand it immediately. In real life it's usually like "each ball can have certain chance to be red or green", in that case n is highly likely to be in the middle instead of equally distributed among [0,100].
- WCSTombs 3y agoI guess I'm late to the party, but here's my take. There are 100 balls. First the host chooses N uniformly from [0, 100] (unknown to us) and makes N of them red and 100-N of them green. But it's annoying to paint 100 balls, right? So he does it this way instead: the host takes 100 white balls and puts them all in a row. Then he takes a black ball and puts it between balls N and N+1, and he declares to himself that all the white balls to the left of the black one will be "red," and all to the right will be "green." Then he has us randomly select two white balls without replacement, and depending on which side of the black ball they were, he'll paint just those two balls red or green accordingly before showing us! Since we never see the other 98 unpainted white balls, we'll never know the difference between this setup and the original. (I think it's intuitively obvious that this setup is mathematically equivalent to the original, i.e. generates the same distribution, so I won't try to justify that rigorously.) Actually though, the host does it slightly differently, again without changing the underlying distribution: you see, he actually starts with 101 white balls, all in a row, and he begins by randomly selecting one of them and paints it black, and then proceeds as above. But this gives the whole problem away: there are 101 white balls in a row, and three are drawn uniformly at random without replacement. The first one is declared "black," and the other two are red or green depending on their positions relative to the black one. All three-ball sequences are equally likely, so by symmetry, the probability that the black ball is between the second and third is exactly 1/3. The other two balls, the ones we draw, are different colors if and only if the black ball is between them, so the probability that we get two balls of the same color is exactly 2/3. That's the answer: whatever is the color of the first ball we draw, the second one has that color with probability 2/3. Thus, the second ball is red with probability 2/3.
- eigenvalue 3y agoVery cool way to think about it, I like it.