Reuben Morais
Reuben Morais

Reputation: 1021

Normalizing values with unknown bounds

Say I have an integer value coming from a hardware sensor, and I don't know its bounds, what's the best way to normalize this value to a bounded range, like [0-1]?

From experimentation, I know what the upper and lower bounds are likely to be, but I don't have strict values for those. I also know the value grows exponentially.

Upvotes: 2

Views: 2224

Answers (1)

SomeWittyUsername
SomeWittyUsername

Reputation: 18358

You have upper and lower bounds corresponding to MIN_INT and MAX_INT. Map MAX_INT to 1 and MIN_INT to 0; divide each input x by MAX_INT + |MIN_INT|. This will map the values into the required range but it won't necessary be optimal (i.e., you may have unused subranges). If you can approximate the upper and lower bounds, take them and add some value that will ensure safety (i.e., the input can't deviate from the range with this safety value) and replace the MAX_INT and MIN_INT in the mapping with these calculated boundaries.

Upvotes: 1

Related Questions