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?

  • $\begingroup$ Perhaps you can get along with the extended mean value theorem, using the halfway-point instead of the unknown midpoint as approximation, $\frac{h(a)-h(b)}{h(c)-h(d)}\simeq\frac{(a-b)h'(\frac{a+b}2)}{(c-d)h'(\frac{c+d}2)}$. $\endgroup$ – LutzL Jan 31 '17 at 9:06
  • $\begingroup$ Are x, y, z, f real? $\endgroup$ – Raziman T V Jan 31 '17 at 9:39
  • $\begingroup$ Yes, I completly forget that. All the variables are real. @LutzL how can I use that? $\endgroup$ – Diogo Santos Jan 31 '17 at 9:41

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}}$$

  • $\begingroup$ Thanks! That formulat get $t$ in 4 different places, which will make integration hard :( Is there other options? $\endgroup$ – Diogo Santos Jan 31 '17 at 14:36
  • $\begingroup$ By the way, do you have a reference for this approximation? $\endgroup$ – Diogo Santos Jan 31 '17 at 16:13
  • $\begingroup$ Can you correct your answer now that I corrected the error I made in my formula? $\endgroup$ – Diogo Santos Feb 2 '17 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.