Hopefully someone here will have a clue, I've done some searching for numerical distribution formulas but that's a pretty broad categroy. I have multiple numerical buckets (not a set number, it can change each time I run this process) with diffent values in each. I need to add a specific number (that also can change from run to run) spread out evenly so that the buckets with the least are filled up first. The trick is that I'd like to be able to calculate them all at once or a single calculation per bucket. I can easily allocate one at a time (I'm working with whole numbers, but I can do rounding at the end if I need to) and do this, but that is very very slow for the ammount of data I'm looking at. Here's an example:
Bucket 1: 10
Bucket 2: 3
Bucket 3: 4
Bucket 4: 7
Quantity to allocate: 10
Result:
Bucket 1: 10 (+0)
Bucket 2: 8 (+5)
Bucket 3: 8 (+4)
Bucket 4: 8 (+1)
Anyone have any suggestions or any useful links for me? I have some experience with Calculus. What I'm looking for is a formula or data-set algorithm for doing this without looping. At the worst I could loop through the buckets once and run a calculation per bucket, that won't be too slow.
Thanks.
Bucket 1: 10
Bucket 2: 3
Bucket 3: 4
Bucket 4: 7
Quantity to allocate: 10
Result:
Bucket 1: 10 (+0)
Bucket 2: 8 (+5)
Bucket 3: 8 (+4)
Bucket 4: 8 (+1)
Anyone have any suggestions or any useful links for me? I have some experience with Calculus. What I'm looking for is a formula or data-set algorithm for doing this without looping. At the worst I could loop through the buckets once and run a calculation per bucket, that won't be too slow.
Thanks.