I realize the title is a bit odd. But this is a statistics problem that I am trying to figure out, but am stumped. (No no, its not homework, see the bottom for the real explanation)
The premise is simple. You have N buckets. Each bucket can hold H balls. None of the buckets is full. You have D balls already in the buckets, but you don't know where the balls are (you forgot!) You choose a bucket at random to add 1 ball. What is the probability that that bucket will then be full.
Some example possible diagrams, with N = 4, H = 3, D = 4. Each case is just a hypothetical arrangement of the balls. for one of many cases.
Scenario 1: 1 bucket could be filled.
| | | | |
+ - + - + - + - +
| B | | | |
+ - + - + - + - +
| B | B | | B |
+ - + - + - + - +
Scenario 2: 2 buckets could be filled.
| | | | |
+ - + - + - + - +
| | B | B | |
+ - + - + - + - +
| | B | B | |
+ - + - + - + - +
Scenario 3: 0 buckets could be filled.
| | | | |
+ - + - + - + - +
| | | | |
+ - + - + - + - +
| B | B | B | B |
+ - + - + - + - +
The problem is I need a general purpose equation in the form of P = f(N, H, D)
Alright, you've tuned in this far. The reason behind this query on math, is I'm curious in having large battles between units. Each unit could belong to a brigade that contains many units of the same type. however, the battle will progress slowly over time. At each phase of the battle, the state will be saved to the DB. Instead of saving each unit and each health for each unit, I want to save the number of units and the total damage on the brigade. When damage is added to a brigade, the f(N, H, D) is run and returns a % chance that a unit in the brigade is destroyed (all of its HP are used up). This then removes that unit from the brigade decrementing N by 1 and D by H.
Before you launch into too much criticism of the idea. Remember, if you have VAST VAST large armies, this sort of information cannot be efficiently stored in a small DB, and with the limitations of Web, I can't keep the data for all the units in memory at the same time. Anyway, thanks for the thoughts.
I believe this boils down to the probability that the first bucket holds H-1 balls (because your probability is really the probability that the bucket you pick to drop a ball into has H-1 balls. I'm guessing this should be solvable with combinatorics, then, but that is not my strong point.
As a side note: this is not a statistics problem, but a probability problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With