0
$\begingroup$

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?

  • 0
    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)}$.2017-01-31
  • 0
    Are x, y, z, f real?2017-01-31
  • 0
    Yes, I completly forget that. All the variables are real. @LutzL how can I use that?2017-01-31

1 Answers 1

1

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

  • 0
    Thanks! That formulat get $t$ in 4 different places, which will make integration hard :( Is there other options?2017-01-31
  • 0
    By the way, do you have a reference for this approximation?2017-01-31
  • 0
    Can you correct your answer now that I corrected the error I made in my formula?2017-02-02