Update Dataset_study.rmd

Simulation_TimeBetweenEvents
This commit is contained in:
elisaduz 2022-02-08 09:54:28 +01:00
parent 7b09890b44
commit 01d75f5d3f
1 changed files with 25 additions and 5 deletions

View File

@ -138,9 +138,29 @@ PoissonProcess <- function(lambda,T) {
return(sort(runif(rpois(1,lambda*T),0,T)))
}
lambda=2
Ti=5
pp=PoissonProcess(lambda,Ti)
print(pp)
plot(c(0,pp),0:length(pp),type="s",xlab="time t",ylab="number of events by time t")
lambda1=2
lambda2=3
Ti=10
pp1=PoissonProcess(lambda1,Ti)
print(pp1)
plot(c(0,pp1),0:length(pp1),type="s",xlab="time t",ylab="number of events by time t")
pp2=PoissonProcess(lambda2,Ti)
print(pp2)
plot(c(0,pp2),0:length(pp2),type="s",xlab="time t",ylab="number of events by time t")
#time between events
n1=length(pp1)
tbe1=pp1[2:n1]-pp1[1:n1-1]
tbe1
n2=length(pp2)
tbe2=pp2[2:n2]-pp2[1:n2-1]
tbe2
```