Reputation: 304
I tested the following example
from scipy.stats import norm
i=0.2
k=0.5
i==norm.cdf(norm.ppf(norm.cdf(norm.ppf(i)+k))-k)
The result gives False
If I check the value of norm.cdf(norm.ppf(norm.cdf(norm.ppf(i)+k))-k)
, it is 0.19999999999999996
.
Why does this happen? Is there a better way to run the inverse of an inverse function?
Upvotes: 0
Views: 125
Reputation: 11831
Because they are numerical approximations. Just like sqrt(2) * sqrt(2)
is not 2. There is just no floating point number such that it's square (in floating point precision) is exactly 2.
Check out Goldberg's classic What every computer scientist should know about floating point, ACM Computing Surveys 23:1 (mar 1991), pp. 5-48.
Upvotes: 2