Skip to contents

Accumulates count, extremes, and the first four moments over one or more chunks of data, mirroring the C# RunningStatistics class. The accumulator state travels in the return value, so a chunked run holds no C++ state and the result serializes with save().

Usage

running_statistics(x, state = NULL)

Arguments

x

numeric vector, the next chunk of data.

state

a corehydro_running object from a previous call, or NULL (the default) to start a fresh accumulator.

Value

a corehydro_running list with n, minimum, maximum, mean, variance, sd, cv, skewness, kurtosis, and the four raw moments m1 to m4.

Examples

s <- running_statistics(c(1, 2, 3))
s <- running_statistics(c(4, 5, 6), state = s)
s$n
#> [1] 6
s$mean
#> [1] 3.5