Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rulet_dupliranje<-function(poc=0, N=150)
- {
- a=poc
- ulog=1
- trajektorija=vector("integer",N)
- for (i in 1:N){
- if(poc > a+50) {
- plot(trajektorija, type = "b")
- abline(a, 0)
- return(1)
- } else if(poc<(a-100)) {
- plot(trajektorija, type = "b")
- abline(a, 0)
- return(-1)
- }
- poc=poc-ulog
- if(runif(1)<=18/38) {
- poc=poc+2*ulog
- trajektorija[i]=poc
- ulog=1
- } else {
- trajektorija[i]=poc
- ulog=ulog*2
- }
- }
- plot(trajektorija, type = "b")
- abline(a, 0)
- print(poc)
- return(0)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement