Consider a Markov Chain as the random walk over the integers. Consider also Sn r.v. that takes values on S={-1,0,1} with probabilities beta,gamma and alpha. Start with X1=0. Then Xn=X_{n-1}+Sn, for n=2,3,... We also have that E(Sn)=alpha-beta, V(Sn)=alpha+beta-(alpha+beta)^2, thus E(Xn)=(n-1)(alpha-beta) and V(Xn)=(n-1)(alpha+beta-(alpha-beta)^2).
Here is my approach to implement this in R
#case 1: alpha>beta (I considered the particular case where alpha=1/2 and beta=1/4=gamma)
Nsim<-1000
S<-c(0,sample(c(-1,0,1),Nsim-1,replace=TRUE,prob=c(1/4,1/4,1/2)))
Xn<-cumsum(S)
plot(Xn,pch=".",col="red")
abline(0,1/4,col="blue")
#case 2: alpha=beta (I considered the particular case where alpha=1/4=beta and gamma=1/2)
Nsim<-1000
S<-c(0,sample(c(-1,0,1),Nsim-1,replace=TRUE,prob=c(1/4,1/2,1/4)))
Xn<-cumsum(S)
plot(Xn,pch=".",col="magenta")
The case 1 works correctly, as you can see:
But case 2 does not and I don't know why see:
Why does this happen?
Also, the abline()
in this case 2 should have slope 0, am I right?
Could someone please help?
Aucun commentaire:
Enregistrer un commentaire