2
$\begingroup$

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!

  • 0
    @André: You're right, another good catch! Unfortunately I cannot say too much about $x_i$ and $n$ in advance.I've just noted that the solution given by Shai fails too :( At this point, I think the best can do is removing the constraint x_i>a. Thanks2011-08-18

2 Answers 2

1

In view of your example, suppose that $ a = x_1 < x_2 < \cdots < x_n = b, $ where $0 \le a < b \le 1$, and that we want $\hat x_1 ,\hat x_2 , \ldots ,\hat x_n $ such that $ a = \hat x_1 < \hat x_2 < \cdots < \hat x_n \leq b $ and $ \hat x_1 + \hat x_2 + \cdots + \hat x_n = b. $ Noting that $ \hat x_1 + \hat x_2 + \cdots + \hat x_n > na, $ we further assume that $b > na$. Then, you can use $ \hat x_i = a + \frac{{b - na}}{{\sum\nolimits_{i = 1}^n {x_i } - na}}(x_i - a). $ Indeed, all the conditions are satisfied:

$\hat x_1 = a$,

$\hat x_1 < \hat x_2 < \cdots < \hat x_n$,

$\hat x_n = a + \frac{{b - na}}{{\sum\nolimits_{i = 1}^n {x_i } - na}}(b - a) \le a + (b - a) = b$,

$\sum\limits_{i = 1}^n {\hat x_i } = na + \frac{{b - na}}{{\sum\nolimits_{i = 1}^n {x_i } - na}}(\sum\nolimits_{i = 1}^n {x_i } - na) = b$.

In your example, $ \frac{{b - na}}{{\sum\nolimits_{i = 1}^n {x_i } - na}} = \frac{{0.8 - 3 \cdot 0.2}}{{1.4 - 3 \cdot 0.2}} = 0.25, $ hence $ \hat x_1 = 0.2, $ $ \hat x_2 = 0.2 + 0.25(0.4 - 0.2) = 0.25, $ and $ \hat x_3 = 0.2 + 0.25(0.8 - 0.2) = 0.35. $ Note that $\hat x_1 + \hat x_2 + \hat x_3 = 0.8 = b$.

  • 0
    Beautiful answer! It works like a charm.Thank you very much!2011-08-18
0

I'm not sure to understand the question.

You can just normalize them dividing by the sum, so that their sum is equal to $1$ and the multiply each normalized number for b (0.8 in your example) so that now the sum is $b$.

In your example:

$\hat{x}_1=0.8\frac{0.2}{1.4}, ~\hat{x}_2=0.8\frac{0.4}{1.4} ~\hat{x}_3=0.8\frac{0.8}{1.4} $

  • 0
    It does not work since in this case $\hat{x}_1 \notin [0.2,0.8]$.2011-08-18