I am producing code for bridge sampling for Brownian motion to simulate sample paths but I keep getting all zeros for my answer. I have got my code and picture algorithm below.
#Brownian bridge for GBM
Z<-rnorm(1, mean=0,sd=1)
T=1
W_[0]=0
W_[T]=sqrt(T)*Z
k=5
j<-2^(k-1)
W_=rep(NA,nt-1)
for(k in 1:K){
h=h/2
for(j in 1:j){
Z<-rnorm(1,mean=0,sd=1)
W_[2*(j-1)*h]=0.5*(W_[2*(j-1)*h]+W_[2*j*h])+sqrt(h)*Z
print(W_[2*(j-1)*h])
}
}
