-1
$\begingroup$

I want to normalise from 0 to 20

For example right now I do normalisation with dynamic outlier exclusion , using median.

So it works fine for some values like below

[100,200,19,0,200,200,12,19000,14000]

It is converted to

 [5, 10, 0.95, 0, 10, 0.6, 10, 10]

Which is good , I want do normalisation of values greater than median value which give score of 11 to 20 , Something like

  [5, 10, 0.95, 0, 10, 0.6, 20 , 16]

This is the code I use right now

   var upper_lim = median*2;
   var test =   10*Math.min(value, upper_lim )/upper_lim;
$\endgroup$
1
$\begingroup$

Essentially you are creating a mapping, or a function here.

In the first instance you had a maximal score of 10, and you mapped as follows:

$$f(volume) = \left \{ \begin{matrix} 10* volume/200, \quad volume < 200 \\ 10 * 1, \quad volume \geq 200 \end{matrix} \right .$$

You have coded this in JS as (where 200 is upper_lim):

var test =   10*Math.min(value, upper_lim )/upper_lim;

Now you have redefined your mapping to the following:

$$f(volume) = \left \{ \begin{matrix} 10* \frac{volume}{200}, \quad volume < 200 \\ 10 * (1 + \frac{volume-200}{19000-200}), \quad volume \geq 200 \end{matrix} \right .$$

where 19000 is max_volume. The maximum value this function can take is 20.

var test;
if (value < upper_lim)  {
  test = 10 * value / upper_limit 
} else {
  test = 10 * ( 1 + (value-upper_limit)/(max_value-upper_limit) )
}  
| improve this answer | |
$\endgroup$
  • $\begingroup$ var value = 150; var upper_lim = 1275; var max = 1425; var test = 10*Math.min(value/upper_lim, 1+(value-upper_lim)/(max-upper_lim)); test; I get -65 for this inputs. $\endgroup$ – Gracie williams Dec 11 '19 at 21:31
  • $\begingroup$ I have made an adjustment - I'm sure you could have figured that out.. $\endgroup$ – Attack68 Dec 11 '19 at 21:36
  • $\begingroup$ Thank you , you are genius. $\endgroup$ – Gracie williams Dec 15 '19 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.