Hello everyone,
I have a couple of integers, and I want to find a simple and effective way to normalize them into range [0, 1]. Any ideas and code refer?
thanks in advance,
George
Printable View
Hello everyone,
I have a couple of integers, and I want to find a simple and effective way to normalize them into range [0, 1]. Any ideas and code refer?
thanks in advance,
George
Not sure what you mean. If you mean map from one interval to another, then something like this:
(just be sure that Max > Min)Code:int Min = //Minimum value in your interval
int Max = //Maximum value in your interval
int Value = //Value to normalize, maybe from traversing an array
double NormalizedValue = (double)(Value - Min) / (double)(Max - Min);
Using this, in the interval 1 - 5, 1 would map to 0.0, 5 would map to 1.0 and 3 would map to 0.5.