Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

>> q=[0.2 0.2 0.06 0.3 0.4 0.65 0.3 0.23 0.02 0.12 0.134 0.21 0.08 0.

1 0.1 0.02 0.3


0.015 0.2 0.03]
q=

Columns 1 through 9:

0.200000 0.200000 0.060000 0.300000 0.400000 0.650000 0.300000


0.230000 0.020000

Columns 10 through 18:

0.120000 0.134000 0.210000 0.080000 0.100000 0.100000 0.020000


0.300000 0.015000

Columns 19 and 20:

0.200000 0.030000

>> P0=0.8
P0 = 0.80000
>> P=[0.2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
P=
Columns 1 through 10:

0.20000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000


0.00000 0.00000

Columns 11 through 20:

0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000


0.00000 0.00000

//Here is where the algorithm was run to calculate p N(l,t)


>> for i=2:20
for j=i:-1:1
if (j==1)
P(j)=(P0*q(i))+(P(j)*(1-q(i)));
else
P(j)=(P(j-1)*q(i))+(P(j)*(1-q(i)));
endif
endfor
P0=P0*(1-q(i));
endfor
>> PT=P'
PT =
6.4562e-002
1.6288e-001
2.3991e-001
2.3401e-001
1.6166e-001
8.2335e-002
3.1696e-002
9.3672e-003
2.1439e-003
3.8133e-004
5.2659e-005
5.6155e-006
4.5789e-007
2.8120e-008

1.2729e-009
4.1216e-011
9.1483e-013
1.3051e-014
1.0669e-016
//Answer to P1
>> P(3)
ans = 0.23991
//Problem P2 E[pN(l,t)]
>> ex = 0
ex = 0
>> for i=1:20
ex=ex+i*P(i);
endfor
>> ex
ex = 3.6690
//Problem P3 = E[(pN(l,t))2] (E[pN(l,t)])2
>> for i=1:20
ex2=ex2+(i^2*P(i));
endfor
>> ex2
ex2 = 15.997
>> ex^2
ans = 13.462
>> ex2-ex^2
ans = 2.5352
//Problem P4Tranche loss TL with U=2, L=0
TLtL,U (l) = max{min{ l *A(1-R),U}-L,0}
E[TLtL,U (l)] = TLtL,U (l)* pN(l,t)
>> for i=1:20

TL(i)=max((min(i,2)-0),0);
endfor
>> TL
TL =
1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
>> eTL=0
eTL = 0
>> for i=1:20
eTL=eTL+(TL(i)*P(i));
endfor
>> eTL
eTL = 1.9135
//Problem P5TL for U=4, L=2
>> eTL2=0
eTL2 = 0
>> for i=1:20
TL2(i)=max((min(i,4)-2),0);
endfor
>> TL2=TL
TL2 =
0 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
>> for i=1:20
eTL2=eTL2+(TL2(i)*P(i));
endfor
>> eTL2
eTL2 = 1.2832

//Problem P6TL for U=20, L=4


>> eTL3=0
eTL3 = 0

>> for i=1:20


TL3(i)=max((min(i,20)-4),0);
endfor
>> TL3
TL3 =
Columns 1 through 18:
0

Columns 19 and 20:


15 16
>> for i=1:20
eTL3=eTL3+(TL3(i)*P(i));
endfor
>> eTL3
eTL3 = 0.47232
>>

9 10 11 12 13 14

You might also like