How to do simulation

Hi

How I do simulation that get as a input - תמונה

and return Realization of x1,x2,........xT

Not knowing what distribution you are trying to do simulation on, there is not much anybody can do to help. What have you done so far?

Hi

I try to do a simultation for Gambler's Ruin. I wrote this -

r <- 20 #Number of turns
p <- 0.5 # Probability of moving forward
y <- c() # Progress Reporting
x0 <- 0 #initial step
A_new_step <- c()
B_new_step <- c()
a <- -10
b <- 10
random_walk<-function(x0, a, b, p , r){
for(i in 1:r){
y<-0
x<-sample(c(-1,1),size = r , replace = TRUE)
y[i+1]<-y[i]+x
if(y[i] == a ){
A_new_step<-(y[i:(r)] = a)
break
return(A_new_step)
}
if(y[i] == b ){
B_new_step<-(y[i:r] =b )
break
return(B_new_step)

}

}
return(y)

}

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.