CMA creates a streaming algorithm that can be used to keep track of the mean of incoming values.

Format

An R6Class generator object

Methods


Method new()

Creates a new CMA streamer object.

Usage

CMA$new(x = NULL)

Arguments

x

values to be used during initialisation (optional)

Returns

The new CMA (invisibly)

Examples

mean <- CMA$new()


Method update()

Resets the CMA streamer object.

Usage

CMA$update(x)

Arguments

x

values to be added to the stream

Returns

The updated CMA (invisibly)

Examples

mean <- CMA$new()
mean$update(c(1, 2))


Method clone()

The objects of this class are cloneable with this method.

Usage

CMA$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

mean <- CMA$new(c(1, 2))
mean$update(c(3, 4))
mean$value
#> [1] 2.5
#> [1] 2.5


## ------------------------------------------------
## Method `CMA$new`
## ------------------------------------------------

mean <- CMA$new()


## ------------------------------------------------
## Method `CMA$update`
## ------------------------------------------------

mean <- CMA$new()
mean$update(c(1, 2))