Scale numbers to be <= 255?
distribution, java, language-agnostic, math
Solution
I figured a log fit would be good for this, but looking at the results, I'm not so sure.
However, Wolfram|Alpha is great for experimenting with this sort of thing:
I started with that, and ended up with:
r(x) = floor(((11.5553 * log(14.4266 * (x + 1.0))) - 30.8419) / 0.9687)
Interestingly, it turns out that this gives nearly identical results to Artelius's answer of:
r(x) = floor(255 * log(x + 1) / log(2^31 + 1)
IMHO, you'd be best served with a split function for 0-10000 and 10000-2^31.
Problem
I have cells for whom the numeric value can be anything between 0 and `Integer.MAX_VALUE`. I would like to color code these cells correspondingly. If the value = 0, then r = 0. If the value is `Integer.MAX_VALUE`, then r = 255. But what about the values in between? I'm thinking I need a function whose limit as x => `Integer.MAX_VALUE` is 255. What is this function? Or is there a better way to do this? I could just do `(value / (Integer.MAX_VALUE / 255))` but that will cause many low values to be zero. So perhaps I should do it with a log function. Most of my values will be in the range [0, 10,000]. So I want to highlight the differences there.