Page 1 of 1

How normalize works

PostPosted: Sun May 23, 2021 9:52 pm
by tulamide
Since I have reason to believe that some of you might not understand fully what normalizing does, here an explanation.

In general normalizing means to take a set of values and re-scale them (keeping their relative relationship intact), so that they end in the range of 0 to 1. In DSP however, we most often work bipolar, so here normalizing means the same, but for the range -1 to 1.

What normalizing does not do, is stretching or otherwise destroy the relationship of the values. This means, that you will not end up with an array that fills the peaks necessarily. Example:

Code: Select all
our array: 3, 1.5
after normalizing: 1, 0.5
When normalizing, you scan through the array to get the highest positive and lowest negative values, let's call both just "peaks". Whatever peak is going beyond the range the most is the key value, from which a percentage of reduction is calculated. In our example that's 3, and it has to be reduced by 2/3rds to fit into the -1 to 1 range. Now all other values are also reduced by 2/3rds, thus 1.5 becomes 0.5. This way the relationship, that value two is half of value one, keeps intact.

It will not stretch 1.5 to become -1! That's important to understand. That would destroy the established relationship of the values! As a result, our example array would never reach -1.

Code: Select all
our array: 3, 1.5, -2.1
after normalizing: 1, 0.5, -0.7
In this array, we reach -0.7, because 2.1 is still closer to -1 than 3 is to 1, and so 3 is still our key value.

Code: Select all
our array: 3, 1.5, -4
after normalizing: 0.75, 0.375, -1
Now finally we reach -1, but at the same time +1 isn't reached anymore. That's because -4 is now our new key value, and it is to be reduced to a quarter to reach -1, not to a third as before.

If you had the thought, normalizing would somehow make sure the values stretch over the whole range, I hope I could give you enough information as to why that is not the case.

Keep on developing!

Re: How normalize works

PostPosted: Mon May 24, 2021 7:01 am
by Spogg
Thank you!

This explanation is very welcome and, oddly, very pertinent for me right now ;)

Re: How normalize works

PostPosted: Mon May 24, 2021 12:12 pm
by kortezzzz
Thank you, tulamide, as always.

Re: How normalize works

PostPosted: Mon May 24, 2021 5:14 pm
by RJHollins
Well described ... helpful examples [code]

Thanks tulamide 8-)