# NOT RUN {
x <- c(1, 2)
f <- function(x, a) prop.table(c(sum(x), a * prod(x)^(1 / 2)))
iterate(x, f, 100, a = 3)
iterate(x, f, 100, tol = 1e-5, a = 3)
##
iterate(x, function(x) {
result <- c(sin(x[1]^2 + x[2]^2), dnorm(x[1] + x[2]))
prop.table(abs(result))
}, 30)
##
x <- c(1, 2, 3)
f <- function(x) {
n <- length(x)
sigma <- seq(-1, 1, length.out = n)
result <- rep(NA, n)
for (k in 1:n) result[k] <- CES(sigma[k], 1, rep(1 / n, n), x, rep(1 / n, n))
prop.table(result)
}
iterate(x, f, 100)
# }
Run the code above in your browser using DataLab