Balls and Boxes Complicated Problem

  • Context: Graduate 
  • Thread starter Thread starter DavidSmith
  • Start date Start date
  • Tags Tags
    Balls
Click For Summary
SUMMARY

The discussion focuses on calculating the probability of stacking black and white balls in 30 boxes, specifically when the ratio of black balls to white balls exceeds a defined threshold 'p', with a minimum requirement of 'q' black balls. The user provides a Haskell function to compute this probability, utilizing combinatorial mathematics to derive the total arrangements of balls. The example given demonstrates a scenario with 10 black balls and 5 white balls, yielding a probability of approximately 0.98 for the specified conditions.

PREREQUISITES
  • Understanding of combinatorial mathematics and probability theory
  • Familiarity with Haskell programming language
  • Knowledge of factorial and binomial coefficient calculations
  • Basic concepts of random distribution in combinatorial problems
NEXT STEPS
  • Explore advanced combinatorial probability techniques
  • Learn about Haskell's list comprehensions and functional programming paradigms
  • Study the implications of random distributions in statistical modeling
  • Investigate optimization techniques for combinatorial algorithms
USEFUL FOR

Mathematicians, computer scientists, and programmers interested in probability theory, combinatorial algorithms, and Haskell programming.

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:

Similar threads

  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 29 ·
Replies
29
Views
6K
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
10
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K