EMA.Rd
EMA
creates a streaming algorithm that can be used to
calculate the exponential moving average of incoming values
An R6Class
generator object
new()
Creates a new EMA
streamer object.
EMA$new(x = NULL, alpha = 0.5)
x
values to be used during initialization (optional)
alpha
value of the smoothing factor (0.5 by default)
exp_mean <- EMA$new()
update()
Updates the EMA with a stream of new values
exp_mean <- EMA$new(c(1, 2))
exp_mean$update(c(3, 4))
exp_mean$value
#> [1] 3.266667
#> [1] 3.266667
## ------------------------------------------------
## Method `EMA$new`
## ------------------------------------------------
exp_mean <- EMA$new()
## ------------------------------------------------
## Method `EMA$update`
## ------------------------------------------------
exp_mean <- EMA$new(c(1,2))
exp_mean$update(c(3,4))