Balls and Boxes Complicated Problem

  • Context: Graduate 
  • Thread starter Thread starter DavidSmith
  • Start date Start date
  • Tags Tags
    Balls
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 3K views
DavidSmith
Messages
23
Reaction score
0
Consider a set box boxes. Say we have 30 boxes.

And then we have x number of black balls and y number of white balls

And these balls are stacked in the boxes. The total nuber of ways of stacking them is easy to find, but a much harder problem is to find the probability that for anyone of the 30 boxes the ratio of black balls to white balls exceeds a certain value donoted as say 'p' where the number of black balls must exceed another variable denoted 'q' for this ratio to be valid.

For example if you have 10 black balls 5 white balls and 30 boxes find the probability that in anyone of those boxes there will be twice as many black balls than white balls assuming that there must be greater than 2 blacks balls in tat particular box. The balls are randomly placed in the boxes and the placement of one ball has no affect on the placement of another.
 
Physics news on Phys.org
Order of stacking within the boxes does not matter. You know that for a given number of white balls and black balls in a given box (say 4 and 2), the number of ways that you could have those appear in that box is the same as the number of ways that you could arrange 6 black balls and 3 white balls in the remaining boxes. Add up the total ways for each number of white or black balls that satisfies the ratio and the minimum number of black balls, and divide by the total number of ways. I couldn't tell you if this is the quickest way to approach the problem, but it should work eventually.


Edit: Since I'm learning Haskell, I tried this as an exercise
Code:
prob w b s min r = satisfy w b s min r / total w b s min

satisfy w b s min r = sum [countall (w - y) (b - x) (s - 1) | x <- [min..b], y <- [0..w], (y == 0 && x > 0) || x / y > r]

total w b s min = countall w (b - min) s

fac 0 = 1
fac n = n * fac (n - 1)

a `choose` b = fac a / (fac (a - b) * fac b)

countall w b s = ((w + s - 1) `choose` w) * ((b + s - 1) `choose` b)
This seems to work, but I haven't tested it much. For your example, r = 2, min = 3 (i.e. greater than 2), s = 30, w = 5, b = 10, prob gives a probability of about 0.98, which sounds about right.
 
Last edited: