Aproximation to function of error function

151 Views Asked by At

The function: $p = \dfrac{\mathrm{erf}(z)-\mathrm{erf}(f(x))}{\mathrm{erf}(z)-\mathrm{erf}(y)}$

All the parameters of the error function ($z, y, f(x)$) are very large. This leads to catastrophic cancellation when I tried to solve it. I fix it by using either Mathematics two parameters Erf implementation or using the complementary error function. However, I would like to have a nice and fast approximation for $p$ using only elementary functions.

As $p$ is a probability, it is important that $0 \le p \le 1$. I do not need a great precision on $p$ only on the order of $10^{-3}$.

Now, the real problematic question is next. $x$ is a random variable with an Uniform Distribution between $a$ and $b$. I want to know the expected $p$, and for that I'm using

$\int_{a}^{b} \dfrac{p(x)}{b-a} dx$

Now, because the function $f(x)$ is inside an error function, I was never able to get a solution for this integral. My first question exist exactly to go is that direction. Is there any other strategy?

1

There are 1 best solutions below

3
On

For the first part of the problem, considering $$p = \dfrac{\mathrm{erf}(z)-\mathrm{erf}(t)}{\mathrm{erf}(y)-\mathrm{erf}(z)}$$ where $z,t,y$ are large, may be, you could use as a first approximation $$\mathrm{erf}(x)\approx 1-\frac{e^{-x^2}}{\sqrt{\pi } x}$$ This would make $$p\approx\frac{ y\, z\, e^{z^2-t^2}\,-\,t\, y}{t\, y\,-\,t \,z\, e^{z^2-y^2}}$$