in reply to number normalization

You want to produce a linear function mapping the minimum value in a list to 1 and the maximum in the list to 3. List::Util provides min() and max() functions. The coefficient of the linear term will be $m = (3 - 1)/(max(@list)-min(@list)), and the constant term will be $c = 1 - $m * min(@list). The map builtin will be handy to then apply that to the file data in @list.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: number normalization
by Anonymous Monk on Aug 10, 2003 at 04:01 UTC
    can anyone provide a sample equation for a non-linear equation example? i.e. log, exponential, etc. ... (anything else you can think of). i would like to emphasize the numbers that are larger vs. the numbers that are smaller.
      perl -e ' for( 0.03, 0.4, 5, 10 ) { print int(10**$_), "\n" } ' 1 2 100000 10000000000
        how about an equation that would normalize a number based on a non-linear equation similar to this equation ($hi and $lo are the $hi and $lo values in the dataset, and $HIVAL and $LOVAL are the output ranges for the normalized dataset)

        my $num = 1 + ($output{$key}-$lo)*($HIVAL-$LOVAL)/($hi-$lo);


        thanks for all your input!!