in reply to number normalization

Asking the question is answering it!

Use the following algorithm:

  1. Call the minimum of your normalized range norm_min and the maximum of your normalized range norm_max.
  2. Go through your list of figures and find the minimum (mini) and maximum (maxi) of the list.
  3. Go again through the list, subtract mini from your number, multiply by (norm_max - norm_min) / (maxi - mini) and finally add norm_min.
$norm_min=1; $norm_max=3; $mini; $maxi; $mini=<DATA>; $maxi=$mini; @figures=<DATA>; foreach (@figures) { chomp; $mini=$_ if $_<$mini; $maxi=$_ if $_>$maxi; } print "$mini $maxi\n"; foreach (@figures) { chomp; my $result=($_ - $mini) * ($norm_max - $norm_min) / ($maxi - $mini +) + $norm_min; print "$_: $result\n"; } __DATA__ 10 3 50 -8 100 67

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law