dyn_wealth = calc_wealth(win, wealth, win_mult)

### Simulated data

Formulas:

win = rnd < prob_win

dyn_wealth = calc_wealth(win, wealth, win_mult)

final = last(dyn_wealth)

Date: 2019-12-16 15:47:33

win = rnd < prob_win;dyn_wealth = calc_wealth(win, wealth, win_mult);final = last(dyn_wealth)

calc_wealth = function(win, wealth, mult) {
    wealth = c(wealth, rep(NA, length(win)))
    for (i in 1:length(win)) {
        wealth[i + 1] = ifelse(win[i], wealth[i] + mult * perc_invest * wealth[i], wealth[i] - perc_invest * wealth[i])
    }
    return(wealth[-1])
}

### Repeated simulation data

Formula:

win = rnd < prob_win

dyn_wealth = calc_wealth(win, wealth, win_mult)

final = last(dyn_wealth)

Date: 2019-12-16 15:47:35

titanic <- data(titanic, package = "radiant.data", envir = environment()) %>% get()
register("titanic")

diamonds <- data(diamonds, package = "radiant.data", envir = environment()) %>% get()
register("diamonds")