Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (14 sloc) 271 Bytes
x <- 100
n <- 100
a <- array(n)
# lognormal
toss <- function(x)
ifelse(rnorm(1, 0) > 0, x * 1.01, x * 0.99)
# arithmetic
tossAr <- function(x)
ifelse(rnorm(1) > 0, x + 1, x - 1)
for (i in 1:n) {
x <- toss(x)
a[i] <- x
}
plot(a, type = "l")
You can’t perform that action at this time.