R/utils-smooth.R

Defines functions smooth

smooth <- function(
    x,
    old_weight
) {
    backcast <-
        x %>%
        rev() %>%
        purrr::reduce(~ old_weight * .x + (1 - old_weight) * .y) %>%
        return()

    x %>%
        purrr::accumulate(~ old_weight * .x + (1 - old_weight) * .y, .init = backcast) %>%
        magrittr::extract(-1) %>%
        return()
}
GiuseppeTT/RiskParityBrazil documentation built on Dec. 17, 2021, 9:33 p.m.