Suppose I have a number of objects N, and I want to separate them into three or more buckets according to a known ratio, let's say x : y : z.
The value N does not necessarily divide perfectly along this ratio (x+y+z does not necessarily go into N); but two things are important:
- having the ratio that actually ends up in the buckets as close to x:y:z as possible, and also
- making sure that the buckets end up containing numbers that add up correctly to N
And I'd like to write an excel function to do this.
I could probably write an iterative process that puts balls into buckets one-at-a-time, using the bucket that will get the result as close to the real ratio as possible, but I'd like to know if there's a direct calculation I could use for this.
Any ideas? :)
First thing is you should divide $x,y,z$ by their greatest common divisor.
You could put $x \left\lfloor \frac{N}{x+y+z} \right\rfloor$ items in the first bucket, $y\left\lfloor \frac{N}{x+y+z} \right\rfloor$ items in the second bucket, and $z \left\lfloor \frac{N}{x+y+z} \right\rfloor$ items in the third bucket.
After that, you have less than $x+y+z$ items remaining to distribute which is the tricky part. Do you have any ideas about how you would want to define how two three-way ratios are "close" to one another?