Inverse Error function

103 views
Skip to first unread message

cha...@chronoapi.com

unread,
Oct 22, 2017, 12:56:24 AM10/22/17
to Discuss
What's the current best course of action when implementing python ops that require the inverse of the error function

Currently the implementation of `distributions.Normal` uses an implementation of the normal CDF in python, which contains the numerical approximation of the error function within here.

I also see that there's something going on in the XLA world, with what appears to be a lower level implementation of the inverse error function

Would it be worthwhile refactoring the python implementation into an inverse error function, and an inverse normal cdf function which depends on it?

jvdi...@google.com

unread,
Oct 23, 2017, 2:21:22 PM10/23/17
to Discuss, cha...@chronoapi.com
Hello there! Thanks for your interest and questions.


On Saturday, October 21, 2017 at 9:56:24 PM UTC-7, cha...@chronoapi.com wrote:
What's the current best course of action when implementing python ops that require the inverse of the error function

Currently the implementation of `distributions.Normal` uses an implementation of the normal CDF in python, which contains the numerical approximation of the error function within here.
The special_math functions are probably what you want. They use the erf, inverse_erf functions "under the hood" but only when a better approximation doesn't exist. In other words, these functions should be more numerically stable than the erf functions. We might consider adding this logic directly into the erf, inverse_erf functions--Im not actually sure why we didnt do that.

I also see that there's something going on in the XLA world, with what appears to be a lower level implementation of the inverse error function

Would it be worthwhile refactoring the python implementation into an inverse error function, and an inverse normal cdf function which depends on it?
Which depends on the XLA version? I believe the special_math code will automatically use the XLA version of erf if XLA is enabled. 

cha...@chronoapi.com

unread,
Oct 24, 2017, 1:45:39 AM10/24/17
to Discuss, cha...@chronoapi.com, jvdi...@google.com
Hey,

Using special_math was my plan for erf, but I didn't see an inverse_erf in special_math, which was part of my reason for digging into the codebase (and finding the two places where it seemed to be). Could you link me to it if I've missed it (have tried searching the repo for "erfi", "erf_inverse" and "inverse_erf").

Thanks for clarifying on the XLA side of things, that squares with my understanding. I think my confusion stemmed from seeing functionality in XLA that I couldn't see exposed in the python front end.

Joshua Dillon

unread,
Oct 24, 2017, 12:53:32 PM10/24/17
to cha...@chronoapi.com, Discuss
On Mon, Oct 23, 2017 at 10:45 PM, <cha...@chronoapi.com> wrote:
Hey,

Using special_math was my plan for erf, but I didn't see an inverse_erf in special_math, which was part of my reason for digging into the codebase (and finding the two places where it seemed to be). Could you link me to it if I've missed it (have tried searching the repo for "erfi", "erf_inverse" and "inverse_erf").
I think the function you want is in special_math as `ndtri` (The "i" stands for inverse.) 

Thanks for clarifying on the XLA side of things, that squares with my understanding. I think my confusion stemmed from seeing functionality in XLA that I couldn't see exposed in the python front end.
Sure--glad I could help out! Thanks again for your questions! 
Reply all
Reply to author
Forward
0 new messages