Learn R Programming

countSTAR (version 1.0.2)

ergMean: Compute the ergodic (running) mean.

Description

Compute the ergodic (running) mean.

Usage

ergMean(x)

Value

A vector y with each element defined by y[i] = mean(x[1:i])

Arguments

x

vector for which to compute the running mean

Examples

Run this code
# Compare:
ergMean(1:10)
mean(1:10)

# Running mean for iid N(5, 1) samples:
x = rnorm(n = 10^4, mean = 5, sd = 1)
plot(ergMean(x))
abline(h=5)

Run the code above in your browser using DataLab