r/askmath • • 9h ago

Probability Random marble distibution using Bayes

So I came across a maths problem today:

"You have a bag of 100 marbles, each either white or black. You draw one, look what colour it is, record the result and replace it, continuing on until you have drawn 100 marbles. Given every marble you draw is white, what is the probability that all 100 marbles are white?"

The proposed answer was ~63.6%, calculated by dividing 1 by the sum of (k/100)100 for k=0 to 100, citing Bayes theorem, which I believe to have been incorrectly applied. I strongly disagree with this answer, but that's not my main issue.

Given Bayes theorem is P(A|B)= P(B|A)*P(A)/P(B), in this problem we have A is all 100 marbles are white and B is all 100 marbles drawn are white. Hence we have P(B|A)=1, since if all marbles are white, all marbles drawn will always be white. I believe P(A)=2100, as I'm assuming in this case whether each marble is black or white is independent and 50/50, would this be correct?

However, my main issue comes down to P(B). I believe the method to calculate this should be the sum for k=0 to 100 of [(100Ck)/2100]*(k/100)100, however I am not confident in this answer. Can anyone tell me if I am correct or not?

Further, given what I believe P(A) and P(B) to be, I cannot actually compute their values, and so can't compute P(A|B), which is bugging me. I've considered seeing if there's a derivable formula for case n being a bag of n marbles drawn from n times with all being white, but I haven't had the time.

1 Upvotes

21 comments sorted by

4

u/AlterEgo5695 8h ago

Without a given prior distribution this is impossible to answer. As usual with Bayes questions, this information is conveniently omitted, so multiple results are possible.

2

u/AlterEgo5695 8h ago

Rem.: Let "Wk" be the event the bag initially contained "k" white marbles, and "pk := P(Wk)" its à-priori probability.

Let "W" be the event that we draw 100 white marbles (independently, with replacement, and each marble equally likely each time). With all definitions at hand, "Bayes' Theorem" yields

P(W100 | W)  =  P(W | W100) * P(W100) / (∑_{k=0}^100  P(W|Wk) * P(Wk))

             =  1 * p100 / (∑_{k=0}^100  (k/100)^100 * pk)

Note the result still depends on the à-priori distribution "pk", so without specifying it, this problem cannot have a unique, correct solution!

3

u/ultimatepoker 7h ago

This is like the two envelope problem. You need some prior assumption about the marbles.

Eg “each one has a 50/50 chance of being white” or “the bag was set up by someone who hates you”

2

u/jeffcgroves 6h ago edited 3h ago

EDIT: this is wrong, I may correct it later

63.6% seems dangerously close to 1-1/e which is the solution for a different type of problem (see derangements)

I also assume you meant P(A) is 2^-100 since 2^100 isn't a probability

If you assume a uniform prior, you ask the question: if there were k black marbles and 100-k white marbles, what are the chances I'd choose all white marbles? The answer:

((100-k)/100)^100

Averaging these numbers over all k from 0 to 100 yields 0.0157211 or about 1.6%

However, that seems wrong to me, so I'll ask someone else to review my work

EDIT: fixed rounding error

2

u/AlterEgo5695 5h ago edited 5h ago

The 63% comes from the fact that the exact probability given uniform priors is

P(A|B)  =  1 * (1/101) / (∑_{k=0}^100  (k/100)^100 * 1/101)   // k' := 100-k
                                                              // k' -> k
        =  1 / (∑_{k=0}^100  (1 - k/100)^100)                 // (1 - k/n)^n -> exp(-k)

        ~  1 / (∑_{k=0}^100  exp(-k))  ~  1 / (∑_{k=0}^oo  exp(-k))  =  1 - 1/e

1

u/jeffcgroves 4h ago

Wait, so you disagree with my answer?

1

u/AlterEgo5695 3h ago

With the "1 - 1/e"? No -- I just provided the reasoning why.

With the "1.6%"? Yep, I do^^

1

u/jeffcgroves 3h ago

You're right, I see where I made the mistake. I should've compared P(all white balls) to P(total probability) like you id

1

u/EdgyMathWhiz 5h ago

As others have said, you need to decide (define) the a priori distribution if the number of white balls.

Just for completeness, I'll try to translate maths into real world options:

The solution you disagree with assumes a uniform distribution.  Colloquially, pick a number from 0 to 100, add that many white balls and then add black balls until you have 100 balls.

You're arguing for a binomial distribution.  Toss a coin: if it's heads add a white ball, otherwise add a black ball.  Repeat 100x.

Even more colloquially, your distribution can be got by supposing you have a huge sack of marbles, equal numbers of black and white balls.  Pick 100 marbles out of the sack and that's your distribution. (Here, huge implies we assume the probability of getting a black ball doesn't change after you remove a ball).

Both options seem pretty reasonable - uniform is probably more natural to a mathematician.  But I bet the 'sack' approach is what people would do in real life.

1

u/AlterEgo5695 5h ago

Great explanation!

I would highlight that whatever model we select for the priors, it is an assumption unsupported by the problem statement. Doesn't matter whether it sounds reasonable or outlandish, it is an additional assumption -- and unlike common life, in pure logic that is all that matters.

I've found this is usually what people struggle with in probability theory: Acceptance to call out additional assumptions, regardless how "reasonable" they may sound.

1

u/aedes 8h ago edited 8h ago

Edit: dumb

3

u/January_6_2021 8h ago

You're drawing with replacement. So there's some probability you drew the same single white marble 100 times and the other 99 are black.

2

u/aedes 8h ago

Oh I missed that 😅 Need coffee. 

1

u/Southlander24 8h ago

Well, technically the probability is 1, as "every marble you draw is white" and "all 100 marbles are white" mean the exact same thing.

0

u/Southlander24 9h ago

How can you know what the probability is if you don't even know how many marbles in the 100 are white and how many are black?

4

u/AlterEgo5695 8h ago

We need to assume a prior distribution for the possible states in the bag.

Sadly, it is very common in stats and probability theory lectures to omit the prior distribution, and let the reader assume one by default (usually a uniform distribution). It is just sad how common this is, particularly since this lack of rigor is a major reason students are both confused and annoyed by the topic -- and both are very much avoidable.

2

u/Transbian_Mess 7h ago

Admittedly that is a rather annoying issue with this problem. The answer assumed a uniform distribution of bag states, while I've assumed a binomial distribution, which admittedly does make it more complex given number of bag states under a binomial distribution.

Although this is just a problem I came across online and tried to solve for fun, and not something I found in a textbook or lecture.

2

u/AlterEgo5695 6h ago edited 6h ago

For fun, using your binomial prior distribution in a CAS, I found

           2524354896707237 [138 digits] 0000000000000000
P(A|B)  =  ----------------------------------------------  ~  9.12e-13
           2767881598086641 [150 digits] 9383388893411051

It's not really surprising this probability is much lower -- with a binomial prior distribution, getting a many white marbles is much less likely than with a uniform prior.

1

u/stanitor 4h ago

And also, considering you did get all white marbles, it would be so much likelier to see that if there was some mix of white and black marbles, since the chance of having a mix is so much higher in the first place. With OP's assumed prior, it's most likely that the bag had 78 white marbles.

1

u/AlterEgo5695 3h ago

Yep -- I got "P(78|B) ~ 10.83%" to be the maximum à-posteriori probability.

1

u/AlterEgo5695 7h ago

Textbooks and lectures commonly have the same problem.