# Finding the solution for a (differential) equation involving the pdf and cdf of a normal distribution

I have this (differential) equation:

f(x)*x + F(x) = 1

where f(x) is a pdf and F(x) its corresponding cdf. Or similarly,

F'(x)*x + F(x) = 1

I can calculate x numerically, but I want an analytical solution. Perhaps there is a single analytical (exact and closed) solution in general (that would be great), although I only need it for the normal distribution.

The equation comes from this one:

$$argmin_x \{ x(F(x)-1) \}$$

I use the following code in R. It is not meant to be efficient. Once I clarify this problem, I will use a better numerical method (e.g. hill climbing if the function is convex or other methods).

optpred_bidloss_normcalc <- function(me, sd) {
RESO <- 100000
MIN <- 0 # It cannot be negative
MAX <- max(me, 0) + sd   # This is an approximation to the maximum

x <- rep(1,RESO)
y <- rep(1,RESO)
for(i in 1:RESO) {
loc <- MIN + (MAX-MIN)*(i-1)/(RESO-1)
x[i] <- loc
y[i] <- loc * (pnorm(loc, mean= me, sd= sd) - 1)
}

imin <- which.min(y)
sol <- x[imin]

sol
}


* Example *

> mymean <- 10
> mysd <- 0.5
> x <- optpred_bidloss_normcalc(mymean, mysd)
> x
[1] 9.00132
> x* dnorm(x,mean=mymean, sd=mysd) + pnorm(x, mean=mymean,sd=mysd)
[1] 1.000015

-

I'm suspicious about this problem based on doing a little tinkering. First, just looking for a simple homogeneous solution for this problem immediately gives that $F(x) = 1 + 1/x$ is a solution for this differential equation.

The problem is that you have the implicit boundary conditions: $\displaystyle\lim_{x\to\infty} F(x) = 1$ and $\displaystyle\lim_{x\to-\infty}F(x)=0.$

Thus, as $x\to\infty$ you require that $xF'(x)\to 0$ strictly from below and that as $x\to-\infty$ you require $xF'(x)\to -1$ strictly from above.

Couple this with the fact that to be a valid density function, $F'(x)$ has to be non-negative (which rules out the analytical solution I gave $1+1/x$ because the derivative is $-1/x^{2}$ which is negative everywhere) and I'm not convinced that this differential equation admits a valid CDF for its solution.

Also, if what is meant by the question is just that you seek a single value of $x$ that solves the equation when $F$ is the Gaussian CDF, then there won't be a closed form. $F$ in that case is a form of the function erfc(x) which involves the Gaussian integral with no closed form. You could use tables, or Newton's method, to solve it.

Further, if you re-arrange the equation in that case, you get that $$F'(x) = \frac{1-F(x)}{x}.$$ Since $F'(x) > 0 \quad \forall x,$ we know that $x > 0$ if $x$ solves that equation. Further, $x$ cannot be zero. Now consider the right hand side when $x\to\infty.$ $F(x)$ is a CDF, so as $x\to\infty$, $F(x)\to 1.$ Thus the top gets exponentially closer to 0 (certainly at a faster rate than the denominator $x$ is going to $\infty$). We also know that as $x\to\infty$, the Gaussian PDF function decays rapidly to zero, so we'll get an equality in the limit.

While this is not at all a rigorous proof, this suggests to me that there is no solution involving the Gaussian PDF for what you're looking for, except at $x=\infty$.

I could be making a dumb mistake somewhere, though, and would appreciate it if anyone points it out.

For some reason, I am unable to respond to the comments below with comments. In my answer above, I was assuming it had to be the standard Normal CDF, but as you mentioned in the comments, there can be solutions for other distributions.

But anyway, I implemented the relevant normal CDF and PDF, and derivatives, in C++ by modify the code I have linked here to use in Newton's method.

I am not able to get the same result as you when using the same mean and standard deviation. When I try many initial guesses in the range 8.9 to 9.0 for $x$, My code converges to solutions at 8.446.

Have you tried this with a computer algebra system to confirm your answer? Perhaps my code is having a numerical accuracy problem, but I'm suspicious because it's worked for many cases for me before.

-
Thanks so much for your detailed answer. My question was a little bit misleading when saying that I had a differential equation. It is in fact your second interpretation what is right. I want a single value for x. However, I can calculate the values. For instance, with a normal distribution, I can calculate the solutions numerically. For instance, if $\mu=10$ and $\sigma=0.5$ I get $x= 9.0015$. Using this value in my equation yields: x* dnorm(x,mean=10, sd=0.5) + pnorm(x, mean=10,sd=0.5) = 1.000757. I can get closer with more resolution in my approximation. –  Francesco Apr 9 '12 at 16:42
Probably there is an issue here because for the standard normal distribution, the previous equation has a solution at $x = \infty$, as you say. But for normal distributions where the mean is >0, there are solutions. I just wanted to be sure that there is no simple analytical solution to the equation, and that using a numerical approximation makes sense. –  Francesco Apr 9 '12 at 16:47
The website wasn't letting me add comments for a little while. But now it is; I added a bit to my answer above. See if it is useful. –  EMS Apr 9 '12 at 17:36