I have an unending series with no equation, and is random, something like this,
X = 1, 456, 555, 556, 557, 789 ...
Note that I'm getting this list as a stream, and I do not know future values, and I do not know min and max of X
.
How do I find out the inverted normal N(X)
for any x in X
, such that,
N(x) --> 0
if x --> inf
N(x) --> 1
if x --> 0
Read that as, the greater the x
is the closer it should be to 0
, the smaller the x
is the closer it should be to 1
.
How can I achieve such a transformation?
I tried the following:
#python
def invnorm(x):
denom = 1 + math.exp(-x)
return 2 - (2/denom)
invnorm(200)
Out[8]: 0.0
invnorm(20)
Out[9]: 4.1223073843355e-09
invnorm(2)
Out[10]: 0.23840584404423537
invnorm(1)
Out[11]: 0.5378828427399902
Somehow that doesn't give a satisfactory result as my range goes on to a large number, and 200
itself gives 0
and my range will be skewed towards 0
.
OK, so you're basically looking for a continuous monotone function N: [0,∞) → (0,1] such that:
In that case, the "obvious" choice would be N(x) = 1 / (x + 1), or, in Python:
def invnorm (x):
return 1.0 / (x + 1)
Of course, there are also infinitely many other functions that satisfy these criteria, like N(x) = 1 / (x + 1)a for any positive real number a.
Yet another "natural" choice would be N(x) = e−x, or, in Python:
def invnorm (x):
return math.exp(-x)
This can also be rescaled to N(x) = b−x for any real number b > 1 while still satisfying your requirements.
And of course, if we relax the monotonicity requirement (which I just assumed, even though you did not state it explicitly), even weirder functions like Abhishek Bansal's N(x) = sin(x) / x will qualify.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With