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