I was refereed here by stackoverflow.com. With some searching I found this: another balls and bins question, but its not quite what I am looking for. Rather the inverse. IE the expected number of buckets that have H-1 balls in them.
I realize the title is a bit odd. But this is a statistics/probability 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 get too technical, I need to implement this solution to a program. So Integrals are out of the question for now. I'm stuck with algebra and trig functions.
I appreciate the help