简体   繁体   中英

Algorithm to scale large numbers by large factor and small numbers by small factor

I'm looking for an algorithm that can scale a large outlier by a large factor and scale small numbers only a bit (or event keep them the same as before). We don't have to keep exact proportions, but just an idea that large number is still larger than small number.

Eg I have a set 10, 15, 200. Let's define min and max to be 0 and 100 respectively and the scaled values should be within that set (min and max are not predefined and can be adjusted). With the algorithm we could scale them to 5, 6, 20.

Any ideas on the formula on how to scale such numbers?

My use case is data for Venn Diagrams for 3 overlapping sets. I would like to preserve the fact that large set is larger than smaller set, but the large circle shouldn't be 20 times bigger than the smaller one.

You haven't given enough detail to give a specific suggestion, but the general idea is that you want some significant magnitude reduction. In general, we handle this with something like the following:

  • square root (or other fractional root)
  • log (base doesn't really matter; scale as needed)
  • arcTan (limits the result to the range 0-1)

Play with some of your unusual cases to see which you like. The example you posted is closest to the sqrt idea.

UPDATE AFTER COMMENTS

If this is used to choose the radii of circles in a Venn diagram, then sqrt is, indeed, the natural choice to preserve the cognitive interpretation of size (from area). This goes for any 2D scaling -- although note that doing this for a picture with shading ( implied 3D) suggests that cube root would be the proper scale. (ref: How to Lie with Statistics).

This is sometimes not possible, in cases where the inputs are of very different magnitudes. For instance given (1, 1000, 1000000), you might want to use a higher root, or change to log, only to make the smallest shape tractable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM