# Solving equation issue

I have a very simple trial that tries to get the value with a specific probability of not being exceeded, F, based on a Gaussian PDF

pdf = PDF[NormalDistribution[0, 1], r]

cdf[x_] := NIntegrate[pdf, {r, -Infinity, x}]

Solve[0.95 == cdf[x], x]


I get:

During evaluation of In:= NIntegrate::inumr: The integrand pdf has evaluated to non-numerical values for all sampling points in the region with boundaries {{-\[Infinity],0. +x}}.

During evaluation of In:= NIntegrate::inumr: The integrand pdf has evaluated to non-numerical values for all sampling points in the region with boundaries {{-\[Infinity],0. +x}}.

During evaluation of In:= NIntegrate::inumr: The integrand pdf has evaluated to non-numerical values for all sampling points in the region with boundaries {{-\[Infinity],0. +x}}.

During evaluation of In:= General::stop: Further output of NIntegrate::inumr will be suppressed during this calculation.

During evaluation of In:= Solve::inex: Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help.

Out= Solve[0.95 == NIntegrate[pdf, {r, -Infinity, x}], x]


whereas if I use:

Solve[0.95 == CDF[NormalDistribution[0, 1], x], x]

During evaluation of In:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information.

Out= {{x -> 1.64485}}


How to get a value out of Solve[0.95 == cdf[x], x]?

• Try this ClearAll[ cdf ] ; cdf[ x_?NumericQ ] := NIntegrate[ pdf, {r, -Infinity, x} ]  and then solve. Mar 2, 2020 at 20:25
• Hi @LouisB, it gives me {{x ->cdf-1[0.95]}} Mar 2, 2020 at 21:21
• Ok, I added Clear["Global*"] and now it works... Mar 2, 2020 at 21:26

The problem is that in your version, Solve evaluates cdf symbolically. I add ?NumericQ to the definition to prevent this, and Solve now finds a solution (but warns that the solution might not be unique).
pdf = PDF[NormalDistribution[0, 1], r];
`