[Solved] Heston Simulation Monte Carlo: Slow R code [duplicate]
You will probably speed things up a lot if you get rid of the outer loop and construct an entire column of your matrix at once: nsim <- 1e5 nt <- 200 U <- matrix(NA, nrow=nsim, ncol=200, byrow=TRUE) V_last <- V <- rep(0.04, nsim) U[,1] <- 40 Inv.phi <- function(y,p) ifelse (y <= p, 0, … Read more