0
$\begingroup$

Given a set of numbers

e.g. {1, 2, 3, 4, 5} or { 50, 100} or {50000, 50001}

I want to normalize these into a range with a min and max e.g. 2 >= x <= 50

My current algorithm is $ ((range_{max} - range_{min}) / (x_{max} - x_{min})) * (x - x_{min}) + range_{min} $

This does result is numbers within the range however a set of numbers like {50000,500001} will result in 50000 = 2 and 50000 = 50 which is too skewed. In this case I would like a result still in the range but with 2 numbers closer together e.g. 2 & 3 or 30 & 31 .

What formula could I use to do this? I'm guessing I need to use $\log(x_{max} / x_{min})$ somewhere but I'm not sure how to work it into the equation.

  • 0
    Then pretend that some very big number is in your given set.2012-08-23

1 Answers 1

1

If what you're trying to do is pick radii of points for visualization, I would just use $\max\left(2, 50\sqrt{x/x_\max}\right).$ This accomplishes two things: the area of the point becomes proportional to the value, and extremely small values get clamped so their points are not too small to be visible.

  • 0
    Representing the magnitudes would be better for display as the radius in a scatter chart so yes, I am going to need to do something special for negative values,2012-08-23