WelfordAlgorithm: Welford Algorithm for Incremental Mean, Variance and Standard...

Description Format Methods Author(s) Examples

Description

It handles a stream of numbers and computes descriptive values without a prior knowledge of how many values you have. It basically computers values coming from a stream of numbers. 06 - January - 2020

Format

An R6Class object

Methods

Public methods


Method new()

Object initialization

Usage
WelfordAlgorithm$new(keep = FALSE)
Arguments
keep

Keeps all values in memory. Default is FALSE to save memory.


Method clear()

Empties out the list of values and resets all calculations

Usage
WelfordAlgorithm$clear()

Method push()

Pushes one single element in the stream

Usage
WelfordAlgorithm$push(x)
Arguments
x

The value to push in the stream


Method pushList()

Pushes a list of values in the stream

Usage
WelfordAlgorithm$pushList(l)
Arguments
l

The list to push in the stream


Method getDataValues()

Returns a vector of values

Usage
WelfordAlgorithm$getDataValues()

Method numDataValues()

Return the number of values processed so far

Usage
WelfordAlgorithm$numDataValues()

Method mean()

Returns the mean

Usage
WelfordAlgorithm$mean()

Method variance()

Return the variance

Usage
WelfordAlgorithm$variance()

Method standardDeviation()

Returns the standard deviation

Usage
WelfordAlgorithm$standardDeviation()

Method print()

Prints the current status of the stram

Usage
WelfordAlgorithm$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
WelfordAlgorithm$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Author(s)

Alberto Calderone <sinnefa@gmail.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- WelfordAlgorithm$new()
x$push(4)
x$pushList(c(3,6.5,4))
x
y <- x$getDataValues()
y
print(x$numDataValues())
print(x$mean())
print(x$standardDeviation())
print(x$variance())

Sinnefa/WelfordAlgorithm_R_Package documentation built on Nov. 12, 2021, 2:31 a.m.