First Indepent Code!
1st independent work of coding, ever!
i am so happy after spending 10+ hr working on a iteration function---I finally worked it out!
First of all, i gotta admit that I've got no talent in computer programming.
For those Com-Sci people, pls don't laugh at me although the following might just seem to be a little piece of cake.
But for me, it's like a milestone. \clap/\clap/!!!
Now, here it comes...
# Poisson (20) and poisson (5)
panjer.dis = function (k){
a=0
b=20
lambda=5
if (k==0) exp(20*(dpois(0,lambda)-1))
else {
g = numeric(0)
g[1]= exp(20*(dpois(0,lambda)-1))
p=1/(1-a*dpois(0,lambda))
for (i in 1:k){
q=(a+b*(1:k)/i)*dpois((1:k),lambda)
g[i+1]=p*sum((q[1:i]*g[i:1]))
}
g[i+1]
}
}
panjer.dis(0);panjer.dis(1);panjer.dis(2);panjer.dis(3)
#g_0;g_1;g_2;g_3
panjer.dis(100)
From Dec. 18-20, i'm gonna modify this function; make it capable to estimate the probabilty of ruin; and compare the probabilities of ruin under different policies.
Now, i can go to DR. Jones' house to party--theme tonight: cowboy, and do some line-dancing!
i am sure we will have some "fun before the finals"!!!
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment