movEmean: Basic Exponential Moving Mean

Description Usage Arguments Details Value Examples

View source: R/RcppExports.R

Description

This function returns a basic exponential moving average (EMA) of the given vector.

Usage

1
movEmean(vec, n = 1L, smFac = NULL)

Arguments

vec

A numeric vector.

n

An integer: moving window size, with 1 as default

smFac

A number: smoothing factor, with default 2/(n+1), see details below.

Details

This function makes fairly efficient the computation of EMA, which dubbed as basic exponential smoothing, the same section of https://en.wikipedia.org/wiki/Exponential_smoothing. It provides an access to define smFac yourself, i.e the smoothing factor, whose default is 2/(n+1).

Value

This function returns a vector whose length is the same as that of vec.

Examples

1
2
movEmean(c(1, 4, 3, 6, 8), 2, smFac = 1/3)
movEmean(c(1, 4, 3, 6, 8), 2)

RcppMovStat documentation built on Jan. 30, 2018, 5:04 p.m.