General problem
I am trying to find an analytical solution to the following problem: Given a vector $v$ with non-negative entries, find a way to normalize it into a vector $v'$ such that:
- If $v_i < v_j$, then $v_i' < v_j'$
- $v'_i \in [0, c_\max]$, so each entry is bounded below and above
- $\sum_i v'_i = K$
I have been trying to find a non-iterative solution for a few days. I want to find a solution that only uses "simple" operations, eg rescaling, subtracting the mean, etc, but I simply cannot find anything.
Typical values
Some "numerical" details for the problem I am interested in:
- $v$ contains $N > 1$ values, say 100 or 1000, but the solution should not depend on the length.
- $c_\max$ is a scalar, and $K$ is also a scalar.
Ideally, I would like to use operations that can be computed easily in numpy and by simple function, I mean I would like to use only differentiable operations, or in the worst case if not possible, some min/max, but no clipping.
Special case
For the special case $c_\max = 2$, you can do the following:
$\mu = \frac{1}{N}\sum_i v_i$. Let $m = \max_i |v_i|$. Then, the vectoz $v'$ such that $v'_i = 1 + \frac{v_i - \mu}{m}$ works. I don't know how to generalize this to the general case, or even whether this approach can generalize.
Any suggestions on how to proceed would be extremely helpful.