1
$\begingroup$

I have a set of numbers:

[9, 8, 6, 4000]

I want to plot a bar chart and I want to normalize only the 4000 number to 4, so the range of Y axis will be [0, 9]. Under the 4 bar I would write * 1000 so the user would know that this value is normalized.

But I don't want to normalize a set of numbers like this:

[1500, 2000, 3500, 4000]

In that case the range would be [0 - 4000].

Is this possible to achieve with some simple math formula?
How can i define the limit for normalizing?

Set can have more than four elements!

  • 0
    English is subject to misinterpretation. I meant that he has only 4 values? with such a big range? I am not following whats your point?2012-03-14

1 Answers 1

1

Brute Force always helps:

Pseudo Code:

vec_min = min(A); vec_max = max(A); deciding_factor = log10(max/min); if(deciding_factor) > 1 for i=1:length(A) if(A(i)>vec_min*(10^floor(deciding_factor))) A(i) = A(i) / 10^(floor(deciding_factor)); print(i was normalized);  Done 

I used floor to approximate downwards.

I used log10 to determine how many orders of magnitude the max element is from the minimum element.

  • 0
    You could add `absolute or abs()` in case you want to compare magnitudes.2012-03-13