##################################### # Blatt 4, Aufgabe 4 ##################################### # Generates a realization of a compound Poisson process (CPP) at # time "time", where the Poisson process has intensity "intensity" # and the jump distribution is exponential with parameter "characteristic" CompoundPoissonProcess<-function(time, intensity, characteristic) { # Finde the number of jumps before time "time" n<-PoissonProcess(intensity, time) sum<-0 # Sum over the correct number of jumps whose # distribution is exponential with paramter "characteristic" if(n>0) { for(i in 1:n) { u<-runif(1) t<- -1.0 * log(u)/characteristic sum<- sum+t } } #cat(paste("Realization CPP: ", sum,"\n", sep="")) return(sum) } # Generates a realization of a (homogeneous) Poisson # Process at time "time" with intensity "intensity". PoissonProcess<-function(intensity, time) { sum<-0 m<-0 # Find the number of jumps before time "time" # when the inter-arrival-times are exponential # with parameter "intensity" (see Blatt 2, Aufgabe 1). while(sum