# Quantile and inverse Quantile

I am trying to calculate the probability that [Nm ≤ n] and this is given by the following equation:

where N denotes the NormalDistribution

and further:

and

In order to do so, I entered the following in Mathematica:

m = 30; (*number of banks*)
n = 5;(*number of defaults*)
AssetV = 100;(*asset value at T*)
DebtV = 80;(*debt value at T*)
r = 0.2;(*annual drift*)
σ = 0.3;(*annual volatility*)
T = 5;(*years*)
ρ = 0.5;
y = n/m // N (*!y must be numeric value!*)

(*calculation of C*)
Ct = (Log[AssetV/DebtV] + (r - 0.5*σ^2)*T)/(σ*Sqrt[T])
(*definition of C, and using Ct because C is a protected symbol*)

(*calculation of p bar*)
p = (1 + Erf[(-Ct)/Sqrt[2]])/2


then $N^{-1}(p)=a$

a = ((1 + Erf[(p)/Sqrt[2]])/2)^-1


$N^{-1}(n/m)=b$

b = ((1 + Erf[(y)/Sqrt[2]])/2)^-1


the whole expression between the brackets is symbolized by s

s = ((1/Sqrt[ρ])*((Sqrt[1 - ρ]* b) - a) )


so far it works, I also get the results when I apply the Quantile function. However, as soon as I enter the following it does not work anymore:

PROB = (1 + Erf[(s)/Sqrt[2]])/2


can anybody please help me, and maybe tell me if there is a more elegant and quicker way to calculate everything?

Thank you

-
There is still a Subscript[C, t] in your code that you probably want to replace with Ct. Furthermore, if I examine the equation for b, it looks like r=n/m. This is not true for the numbers you provide. You define a variable y that is never used. –  Sjoerd C. de Vries Jul 15 at 21:47
@ Sjoerd C. de Veries I made the changes, but it's still not running. –  Milan Ivica Jul 16 at 6:54
BTW. if I type in b = ((1 + Erf[(0.166667)/Sqrt[2]])/2)^-1, why do I get two outputs?, and how I can say Mathematica just to use one? –  Milan Ivica Jul 16 at 7:20
@Sjoerd C. de Vries I am asking because when I enter: N[CDF[NormalDistribution[0, 1], 0.166667], 5]^-1, sometimes I get one and sometimes two outputs –  Milan Ivica Jul 16 at 7:34
I'm afraid I don't see any of the problems you report. Could you please restart your kernel and try again? What did you mean by "it's not running"? I get output without error messages. –  Sjoerd C. de Vries Jul 16 at 9:04