I have a math question more than an applescript question.
I have various lists of numbers, e.g. {-10, …, 75}, {325, …, 1220}, {1, …, 12}, etc. I need to “map” each of these lists (individually) into a range from 0 to 100, where the smallest number in the list maps to 0 and the highest number maps to 100 and the rest of the numbers in each list maps proportionally.
I can’t figure out how to do this.
Thanks in advance,
Brad
Hi.
(number - lowest) / ((highest - lowest) / 100)
The ((highest - lowest) / 100) can be precalculated.
Hi Brad Bumgarner,
this is my first post in this forum, greetings from Germany. I have read your quest and i found it interesting to solve the problem “ and voila, here is a universal handler:
my wertemappen(0, 100, {-77, 24, 60, 408})
on wertemappen(min, max, liste) # by Macmissionar “ Danke an Britta, 30.8.2012
set gemappteliste to {}
set spanne to ((last item of liste) - (first item of liste))
set neuespanne to max - min
repeat with i from 1 to count items of liste
set end of gemappteliste to (((item i of liste) - (item 1 of liste)) / spanne) * neuespanne + min
end repeat
return gemappteliste
end wertemappen
You can tell my wertemappen() and he returns the new list with mapped values. Hope that helps. Can you tell me the problem for this question? Thank you.
Thanks for your responses, I’ve never been good at figuring these things out.
Thanks,
Brad
Brad, can you tell me for what is this handler needed? What is your Application . I think at color sliding controls in Photoshop and InDesign (color gradients)
I am using this as a way of rating NFL football teams based on their statistics.
Brad