Description Format Methods Examples
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)
The new EMA
(invisibly)
exp_mean <- EMA$new()
update()
Updates the EMA with a stream of new values
EMA$update(x)
x
a vector of values to update the EMA
The updated EMA
(invisibly)
exp_mean <- EMA$new(c(1,2)) exp_mean$update(c(3,4))
clone()
The objects of this class are cloneable with this method.
EMA$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | exp_mean <- EMA$new(c(1, 2))
exp_mean$update(c(3, 4))
exp_mean$value
#> [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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.