I'm not a mathematician, so sorry for the possible trivial question.
I have a set of values in $x_i\in[0,1]$ (say for $i=1,\ldots,n$) whose sum can be greater than $1$. Now I want to scale them so that the new values $\hat{x}_i$ fall in the interval $[a,b]\subseteq[0,1]$ such that $\sum_{i=1}^n\hat{x}_i=b$.
For instance, suppose that $x_1=0.2, \quad x_2=0.4, \quad x_3=0.8$ and that $[a,b]=[0.2,0.8]$. How can I compute $\hat{x}_1,\hat{x}_2,\hat{x}_3$ such that $\sum_{i=1}^3\hat{x}_i=0.8$?
Note: I've found a similar question here: https://math.stackexchange.com/questions/43698/range-scaling-problem. But the proposed solution fails to satisfy the constraint.
Thank you very much in advance!