Distribute weights across items with a smooth curve

156 Views Asked by At

Is there a function I could use to smoothly distribute a total weight W across N items with the first K items getting a specified percentage P of the weight? For example, distribute 100 points across 100 items, with the first 10 items getting 50% of the weight.

This seems like something I could do with a (quadratic?) Bézier curve with a start of $(1,1)$ and end of $(0,0)$. I could scale the inputs/outputs from 0 to 1, based on the number of items and weight ($x=\frac iN, w=yW$). However, I'm not sure how to choose the control points nor whether this is a good approach.

(Apologies for the poor terminology. Edits welcome.)

1

There are 1 best solutions below

4
On

There is no need to use Bézier curves, as hinted in the comments. In fact, trying to design a quadratic or cubic Bézier curve so that the point weights are integrals over equally sized strips on $[0,N]$ produces negative weights for some points, which would not be fancied.

Instead, to get a really smooth distribution use a geometric series. Let the first point have weight $a$, the second $ar$, the third $ar^2$ and so on until the last point has weight $ar^{n-1}$. Then we have $$a\frac{1-r^N}{1-r}=W\ \text{and}\ a\frac{1-r^K}{1-r}=PW$$ where $0<P<1$. Dividing the second relation by the first produces $$\frac{1-r^K}{1-r^N}=P$$ For the given values of $N=100,K=10$ and $P=\frac12$, r works out as approximately 0.933125. Substituting this into either equation allows us to derive a, which is approximately 6.694105.