MOVRMS

Purpose:

Calculates the moving RMS of a series.

Syntax:

MOVRMS(series, N, rampflag, "naflag", "edgeflag")

series

-

A series or array, the input series

N

-

An integer, the number of points to compute the variance as the series is processed.

rampflag

-

Optional. An integer, endpoint averaging flag.

0

:

none

1

:

up (default)

"naflag"

-

Optional. A string, the NA handling method.

"omitnan"

:

ignore NA values (default)

"includenan"

:

include NA values

"edgeflag"

-

Optional. A string, the edge processing flag.

"full"

:

process all segments (default)

"center"

:

center the result within the overlapping N point segments

"discard"

:

only process segments of length N, ignore partial segments

"shrink"

:

shrink the size of both the start and end segments to the actual number of samples in the segments

Returns:

A series or table.

Example:

W1: {4, 3, 2, 1, 2, 3, 4}

W2: movrms(w1, 3)

 

W2 == {4, 3.5355, 3.1091, 2.1602, 1.7321, 2.1602, 3.1091, 3.5355, 4}

 

W2 computes the RMS of each overlapping moving segment of length 3 but the segment length adjusts from 1 to 3 at the start edge and from 3 to 1 at the end edge. The segment divisor adjusts accordingly.

Example:

W1: {4, 3, 2, 1, 2, 3, 4}

W3: movrms(w1, 3, 0)

 

W3 == {2.3094, 2.8868, 3.1091, 2.1602, 1.7321, 2.1602, 3.1091, 2.8868, 2.3094}

 

Same as above where the segment length adjusts from 1 to 3 at the start edge and from 3 to 1 at the end edge but N is fixed at 3 and the segment divisor remains fixed at 3.

Example:

W1: {4, 3, 2, nan, 2, 3, 4}

W2: movrms(w1, 3)

W3: movrms(w1, 3, "includenan")

 

W2 == {4, 3.5355, 3.1091, 2.1602, 1.7321, 2.1602, 3.1091, 3.5355, 4}

W3 == {4, 3.5355, 3.1091, nan, nan, nan, 3.1091, 3.5355, 4}

 

W2 ignores all NA values by removing the NaN from the segment and adjusting the segment size down.

 

W3 includes NaNs and produces an NaN if the segment includes an NaN.

Example:

W1: {4, 3, 2, nan, 2, 3, 4}

W2: movrms(w1, 3, 0)

W3: movrms(w1, 3, 0, "includenan")

 

W2 == {2.3094, 2.8868, 3.1091, 2.5495, 2, 2.5495, 3.1091, 2.8868, 2.3094}

W3 == {2.3094, 2.8868, 3.1091, nan, nan, nan, 3.1091, 2.8868, 2.3094}

 

Same as above except the segment divisor remains fixed at 3.

Example:

W1: {4, 3, 2, 1, 2, 3, 4}

W2: movrms(w1, 3, "center")

W3: movrms(w1, 3, 0, "center")

 

W2 == {3.5355, 3.1091, 2.1602, 1.7321, 2.1602, 3.1091, 3.5355}

W3 == {2.8868, 3.1091, 2.1602, 1.7321, 2.1602, 3.1091, 2.8868}

 

W2 and W3 compute a 3 point centered moving RMS where the result at point N is the average of points N-1, N and N+1.

 

For W2, the segment length and segment divisor adjust from 1 to 3 at the start edge and from 3 to 1 at the end edge.

 

For W3, the segment length also adjusts from 1 to 3 at the start edge and from 3 to 1 at the end edge but the segment divisor remains fixed at 3.

Example:

W1: {4, 3, 2, 1, 2, 3, 4}

W2: movrms(w1, 3, "discard")

W3: movrms(w1, 3, 0, "discard")

 

W2 == {3.1091, 2.1602, 1.7321, 2.1602, 3.1091}

W3 == {3.1091, 2.1602, 1.7321, 2.1602, 3.1091}

 

W2 and W3 compute a 3 point moving RMS for all overlapping segments that contain exactly 3 samples. Shorter segments at the start and end edges are discarded. The rampflag parameter has no effect.

Example:

W1: {4, 3, 2, 1, 2, 3, 4}

W2: movrms(w1, 3, "shrink")

W3: movrms(w1, 3, 0, "shrink")

 

W2 == {4, 3.5355, 3.1091, 2.1602, 1.7321, 2.1602, 3.1091, 3.5355, 4}

W3 == {4, 3.5355, 3.1091, 2.1602, 1.7321, 2.1602, 3.1091, 3.5355, 4}

 

Same as the first example, where the RMS of each overlapping moving segment of length 3 is computed but the segment length and segment divisor adjust from 1 to 3 at the start edge and from 3 to 1 at the end edge. The rampflag is essentially forced to 1.

Example:

W1: {4, 3, 2, 1, 2, 3, 4}

W2: movrms(W1, length(W1))

 

W2[length(w1)] == rms(w1) == 2.9032

Remarks:

MOVRMS computes the moving discrete root mean square value. For each section of length N, the RMS value is defined as:

 

RMS

 

For speed, this routine uses the built-in function MOVAVG.

 

See LINRMS to compute a phase-less moving RMS.

See Also:

BLOCKRMS

COLRMS

LINRMS

MOVAVG

MOVSTD

MOVVAR

RMS