Ok, so this is the question.
Let’s say I have a given value: 2000;
and I have the following placeholders
ph1 -> 15% of the total
ph2 -> 10% of the total
ph3 -> 25% of the total
ph4 -> 10% of the total
ph5 -> 30% of the total
ph6 -> 10% of the total
however each value may float 0,1% in any direction. And I have to distribute the delta to the remaining placeholders. The “spent” total has to be the most near to the the 2000 mark (0.1% variation maximum). Is there any algorithm I can use?
Thank you guys
If you keep track of the percentage of the total remaining, then it should be easy to distribute your error (the “delta”) proportionally by calculating the percent of the remainder represented by each later entry.