I have a dataset of positive integers that I want to scale so that the output range is [0.0,1.0]
and the median maps to 0.5
.
Is this possible to do at all?
If so, how can I do it in Python using
scipy
orsklearn
?
I have a dataset of positive integers that I want to scale so that the output range is [0.0,1.0]
and the median maps to 0.5
.
Is this possible to do at all?
If so, how can I do it in Python using scipy
or sklearn
?
This is mathematically impossible to do in general with a linear scale plus translation (that is x[i] = a*x[i] + b
).
Scaling the data to the [0,1] interval is easy. It should be x=(x-min(x))/(max(x)-min(x).
If you just wanted the data to have a median of 0.5 without the [0,1] requirement, you could do x = 0.5*x/median(x).
But if you want both to be true, it can't be done with scaling.