search for: looprec

Displaying 1 result from an estimated 1 matches for "looprec".

Did you mean: looprep
2011 Nov 27
1
generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})
...* x[2] + alpha * x[3] ..... below are the methods I have tried and failed miserably, some are just totally ridiculous so feel free to have a laugh but would appreciate if someone can give me a hint. Otherwise I guess I'll have to give RCpp a try..... ## Bench mark the recursion functions loopRec <- function(x, alpha){ n <- length(x) y <- double(n) for(i in 1:n){ y[i] <- sum(cumprod(rep(alpha, i)) * rev(x[1:i])) } y } loopRec(c(1, 2, 3), 0.5) ## This is a crazy solution, but worth giving it a try. charRec <- function(x, alpha){ n <-...