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
    Multiply all the $x_i$ with $\frac{\max_i x_i}{\sum_i x_i}$.2011-08-18
  • 0
    Conditions need to be modified? Suppose $a=0.2$, $b=0.8$ specified and $n=7$. Whatever the $x_i$, we can't have $\hat{x}_i$ falling in $[a,b]$ and $\sum\hat{x}_i=b$, since $\hat{x}_i \ge 0.2$ so $\sum \hat{x}_i \ge 1.4$.2011-08-18
  • 0
    @JM: can you be more explicit, that is $\hat{x}_i=\ldots$?2011-08-18
  • 0
    @André: good catch. Indeed, this could be a problem. However, I think that a simple normalization should solve it. That is: $x_i \rightarrow \frac{x_i}{\sum_{i}x_i} \rightarrow \hat{x}_i$. Do you?2011-08-18
  • 0
    @seg.fault: That's fine. It's also giving up on the condition that (say) all $\hat{x}_i$ are $\ge 0.2$. The point is that we can't just freely specify $a>0$ in advance, independent of $n$. What size are your "real" $n$ for your application? What are the real hoped for $a$, $b$, roughly? Are you willing for $\sum \hat{x}_i$ to be replaced by something like $\sum \hat{x}_i^2$? At least one of your wished-for specifications needs modification. The one you suggest above gives up on $a$. If it's OK with you, that's just fine, then multiply all by $b$ to make the sum $b$.2011-08-18
  • 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