Live data from Hacker News

A confusing probability question: Red and green balls in an urn

colab.research.google.com

81–90 of 169 posts

Re: A confusing probability question: Red and green balls in an urn

#81
post #20

It'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).

I'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 t…

Forgive 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.

Re: A confusing probability question: Red and green balls in an urn

#82
post #46

Having 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…

The 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.

Re: A confusing probability question: Red and green balls in an urn

#83
Early 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?"

Re: A confusing probability question: Red and green balls in an urn

#84
post #75

Never 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…

I 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.

Re: A confusing probability question: Red and green balls in an urn

#85
post #81

Earlier quoted context omitted.

I'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 t…

Forgive 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 numbe…

The revised code here gets to correct estimate: https://news.ycombinator.com/item?id=39198581

Roughly similar to what I wrote too.

Re: A confusing probability question: Red and green balls in an urn

#86
post #75

Never 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…

Both of those have the same answer. Why would they not?

Re: A confusing probability question: Red and green balls in an urn

#87
Not 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.

Re: A confusing probability question: Red and green balls in an urn

#88
post #51

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%

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.

Re: A confusing probability question: Red and green balls in an urn

#89

Earlier quoted context omitted.

I'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 informatio…

It'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?

[dead]
Post reply on HN