Search code examples
javascriptdistribution

How to distribute values linearly


I have a total of 10,000 that I want distributed among 99 points, not divided equally but on an increasing linear curve. So while the first point may be worth only [e.g.] 10, each following point would be worth more until the final one is worth [e.g.] 250 or so. But all points need total the 10,000. How could I do that?

// Edit: The first and last values of 10 and 250 are just examples, they could be anything really. The total though (10,000) needs to be variable, so I could change it to 20,000 later if needed.


Solution

  • Take the 99 cells with values [1,2,3,4,..,99] and multiply each number by S/4950 where S is the desired sum (e.g. S=10,000).