Remove outliers while mapping one range to another?
I asked this question on how to map a range between 0 and n to 0 to 9.
I use this solution and it works:
private int MapValue(int value, int n)
{
int output = (int)Math.Ro开发者_如何学Pythonund((10.0 / (n - 1) * (value - 1)) - 0.5, 0);
if (output == -1) return 0;
else return output;
}
Now I encountered another problem. I one example I have the range 0 to 1116. However most values or between 0 and 50 or maybe 0 and 100. So nevertheless most values are mapped to the same color. How can i avoid that such outliers tamper with my mapping?
You need to find the outliers and then map them to the high or low values in the range. There are many different ways to find the outliers. One simple way. Search for "how to find outliers" and you'll find lots of solutions.
精彩评论