rescaling list of numbers
Crossposted to the numerical ****ysis group. You want to
guarantee that the sum, when evaluated, is exactly
1.0 to the last bit? It seems to me the most troublesome
cases will arise when:
- The a's differ in sign and
- differ widely in magnitude
I think you'll get the most accurate sum if you add them
in order of increasing magnitude. But I'm not completely
sure about that -- what if a_n is very close to -a_{n-1}?
All I can come up with is what you'd probably call ad-hoc:
Add the numbers (in whatever order seems best), divide
by the sum, then reset a_n = 1.0 - sum(a_1,..., a_{n-1}).
- Randy
|