Solving equation involving cdf of standard normal distribution

200 Views Asked by At

How do I solve the following equation for $n$ using Maple: $$2\Phi\left(\frac{0.01}{\sqrt{\frac{\pi^{5}-2\pi^{4}}{2\pi^{2}n}}}\right)-1=0.95,$$ where $\Phi(x)$ denotes the cdf of a standard normal distribution.

Thanks in advance

3

There are 3 best solutions below

0
On BEST ANSWER

In Maple the inverse of the CDF is implemented as the Quantile command from the Statistics package. For example,

restart; with(Statistics):
Quantile( RandomVariable(Normal(0,1)), 0.975 );

             1.95996398453944

If you prefer you can skip several easy steps and directly write down the reformulated equation,

restart;
with(Statistics):
X:=RandomVariable(Normal(0,1)):
0.01/sqrt((Pi^5-2*Pi^4)/(2*Pi^2*n))=Quantile(X,0.975):
fsolve(%);

                216409.8864

Or it can all be done starting from the originally supplied equation, with no mental rearrangement of the equations required.

restart;
with(Statistics):
X:=RandomVariable(Normal(0,1)):
eq:=2*Phi(0.01/sqrt((Pi^5-2*Pi^4)/(2*Pi^2*n)))-1=0.95:
new1:=isolate(eq,indets(eq,specfunc(anything,Phi))[1]):
new2:=eval(map((Phi@@(-1)),new1),
           (Phi@@(-1))=(p->Quantile(X,p))):
fsolve(new2,{n});

             {n = 216409.8864}

I'll break down some of those steps, for explanation.

restart;
with(Statistics):
X:=RandomVariable(Normal(0,1)):

I'll start with the eq as given.

eq:=2*Phi(0.01/sqrt((Pi^5-2*Pi^4)/(2*Pi^2*n)))-1=0.95:

The only function call to Phi, in eq,

indets(eq,specfunc(anything,Phi))[1];

    Phi(.1e-1*2^(1/2)*Pi/(1/n*(Pi^5-2*Pi^4))^(1/2))

Isolating eq for that call to Phi

new1 := isolate(eq,indets(eq,specfunc(anything,Phi))[1]);

    Phi(.1e-1*2^(1/2)*Pi/(1/n*(Pi^5-2*Pi^4))^(1/2))
    = .9750000000

Applying the inverse of Phi to both side of that new equation.

map((Phi@@(-1)),new1);

    .1e-1*2^(1/2)*Pi/(1/n*(Pi^5-2*Pi^4))^(1/2)
    = (Phi@@(-1))(.9750000000)

The same as previous, but following up by replacing the generic inverse Phi call with a call to Quantile (using R.V. X).

new2:=eval(map((Phi@@(-1)),new1),
           (Phi@@(-1))=(p->Quantile(X,p)));

    .1e-1*2^(1/2)*Pi/(1/n*(Pi^5-2*Pi^4))^(1/2)
    = 1.95996398453944232

Solving that, numerically,

fsolve(new2,{n});

           {n = 216409.8864}

or, if preferred,

fsolve(new2,n);

               216409.8864
0
On

I don't have a working Maple at home, so based on Distributions:Normal and solve, try

with(Statistics)
solve( 2 * PDF( RandomVariable(Normal(0,1)), 0.01/sqrt((Pi^5 - 2 Pi^4)/(2*Pi^2 * n)) ) - 1 = 0.95, n)

Now maybe Maple's solve doesn't know how or recognize that it can apply the inverse CDF, norminv, so we have to do that manually...

with(Statistics)
first = solve( 2*phi - 1 = 0.95, phi)
solve( 0.01/sqrt((Pi^5 - 2 Pi^4)/(2*Pi^2 * n)) = norminv(first), n)

Again, I don't have Maple handy, so these may require a few rounds of tweaking to get right, so feel free to comment with progress or results.

0
On

The explicit solution is

$$n=10000\dfrac{\pi^{3}-2\pi^{2}}{2}\left(\Phi^{-1}(0.975)\right)^2\approx216400$$

using $\Phi^{-1}(0.975)=1.9600$ from a table.