TITLE: How do I convert an array of numbers from an old range to a new range, where the highest valued number is 100 and the lowest valued number is a 0?
QUESTION [0 upvotes]: I am trying to develop weights for a mapping application of mine. I know it's a bit of a weird question, but say we have an array of some values like [1, 5, 7, 9, 3] I want the converted array to have the 9 be replaced with a 0 and the 1 replaced with a 100 as it's the lowest value. What would be the best way to approach this?

REPLY [1 votes]: I think what you're looking for is a min-max normalization. You want to normalize the array but instead of the usual range of 0-1 you want it to be from 0-100, but also reversed I suppose because you want 9 to be 0 and 1 to be 100.
For a value v in the array you have, it can be normalized on this new range via:
$v’ = (v-min)/(max-min) * (newmax-newmin) + newmin$
$v$ is the old value and $v'$ is the new value.
Heres a Python function that would do what I believe you're looking for
{"set_name": "stack_exchange", "score": 0, "question_id": 4133457}