Well, we know what Xi is equal to. So we can substitute n for Xi.

This is equal to the probability Xi is equal to ai times M, plus the square root

of 1 minus ai squared times Zi, is less than or equal to xi bar of t, given n.

So this is then equal to the probability that Zi is less than or equal to xi bar,

t minus ai, times M divided by the square root of 1 minus ai squared.

And that's all conditional on M. Now if you think about it for a second

conditional on M, if we condition on M as we have here then everything on the right

hand side here is a constant. Zi is a standard normal running variable.

So this just becomes the probability that a standard normal running variable is

less than or equal to. This expression here, and so that's equal

to phi of what we have inside here, so that's what the conditional risk neutral

default probabilities are. There are qi of t given n's.

Now let P superscript n, l of t denote the risk neuter probability that there

are a total of l portfolio or defaults before time t.

We may then write pl of t as being the integral for minus infinity to infinity

of p superscript n l of t given M times phi of MdM where phi is the standard

normal PDF. Now if you're wondering where this

expression comes from, well, this is just a standard basic undergraduate expression

for probability. In discrete form, you can imagine the

following. Suppose we want to compute the

probability that X is equal to little x. Well, a standard way of doing this is to

consider another random variable y, and to sum over all possible values of y.

So it's equal to the probability of X equals little x, and Y equals little y.

And this is also equal to the sum over little Y of the probability that X equals

little X. Given Y equals little Y by the

probability that Y equals little Y. So this is a standard expression you

probably all seen before in your undergraduate probability class.

We're just using this here and. In density form rather than discrete

probability mass function form. So M here takes the place of y.

So we have our m here, taking the place of y over here, and so instead of a

summation, we have an integral. And we're integrating with respect to m

instead of summing over the y values here.

So this is standard, so we can now write the probability of l default, and just to

be consistent, I should have put a superscript n there.

So the probability of l default out of the n names by time t, is given to us by

this integral here. So the next task is going to be how do we

compute this quantity? We know phi of M, it's just the standard

normal density. So, we need to compute this quantity

here. We can compute this quantity, then we can

evaluate this integral numerically, and therefore compute this risk-neutral

probability function here. So let's focus on how to compute this

expression here. So, in fact, we can easily do it using an

iterative procedure, and the iterative procedure will work as follows.

So the first thing we're going to do let's initialize.

We're going to have to run a couple of for loops here.

So let's initialize our quantities first of all, we're going to set p 0.

Given M to be equal to 1 minus q1 of M. We're going to set p1, given M to be

equal to q1 of M. And we're going to set p2 given M to be

equal to P3 given M all the way up to Pn given M.

We're going to set all of that equal to 0.

Now, what I'm doing here is, I'm dropping the dependence on n and t here.

So, I don't want the slide to get too cluttered.

If I did I'd have an n in all of these values here.

And I'd have a t in here, and so on. But that's just going to get really

cluttered. So, I won't do that.

So, I'm dropping the dependence of these quantities on n, and t.

So, now we're going to do the following. We're going to run the following for

loop, we're going to say. For i equals 2 up as far as n.

And, for j equals 1 to i. I am going to update these quantities

here that i have already initialized. In particular I am going to say.