MOVSTD

Purpose:

Calculates the centered moving standard deviation of a series.

Syntax:

MOVSTD(series, N, dof, "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.

dof

-

Optional. An integer, the degrees of freedom normalization mode.

0

:

sample standard deviation, normalize by 1/(N-1) (default)

1

:

population standard deviation, normalize by 1/N

"naflag"

-

Optional. A string, the NA handling method.

"omitnan"

:

ignore NA values

"includenan"

:

include NA values (default)

"edgeflag"

-

Optional. A string, the edge processing flag.

"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 (default)

Returns:

A series or table.

Example:

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

W2: movstd(w1, 3)

W3: movstdev(w1, 3)

 

W2 == {0.7071, 1, 1, 0.5774, 1, 1, 0.7071}

W3 == {0, 0.7071, 1, 1, 0.5774, 1, 1, 0.7071, 0}

 

W2 computes a 3-point centered moving sample standard deviation where the result at point N is the sample standard deviation of points N-1, N and N+1. The computation starts at sample 2.

 

W3 computes a 3-point non-centered moving sample standard deviation.

Example:

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

W2: movstd(w1, 3, 1)

W3: movstdev(w1, 3, 1, 1)

 

W2 == {0.5, 0.8165, 0.8165, 0.4714, 0.8165, 0.8165, 0.5}

W3 == {nan, 0.5, 0.8165, 0.8165, 0.4714, 0.8165, 0.8165, 0.5, nan}

 

Same as above except the population standard deviation is computed.

Example:

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

W2: movstd(w1, 3)

W3: movstd(w1, 3, "omitnan")

 

W2 == {0.7071, 1, nan, nan, nan, 1, 0.7071}

W3 == {0.7071, 1, 0.7071, 0, 0.7071, 1, 0.7071}

 

W2 retains NaN values and returns NaN if any NaN is present in the segment.

 

W3 excludes all NaN values by removing them from the segment and adjusting the segment size and segment divisor down.

Example:

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

W2: movstd(w1, 3, 1)

W3: movstd(w1, 3, 1, "omitnan")

 

W2 == {0.5, 0.8165, nan, nan, nan, 0.8165, 0.5}

W3 == {0.5, 0.8165, 0.5, 0, 0.5, 0.8165, 0.5}

 

Same as above except the population standard deviation is computed.

Example:

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

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

W3: movstd(w1, 3, 1, "discard")

 

W2 == {1, 1, 0.5774, 1, 1}

 

W3 == {0.8165, 0.8165, 0.4714, 0.8165, 0.8165}

 

W2 and W3 compute a 3-point moving standard deviation for all overlapping segments that contain exactly 3 samples. Shorter segments at the start and end edges are discarded.

 

W2 computes the sample standard deviation and W3 computes population standard deviation.

Example:

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

W2: movstd(w1, 3)

W3: movstd(w1, 3, "shrink")

 

W2 == {0.7071, 1, 1, 0.5774, 1, 1, 0.7071}

W3 == {0.7071, 1, 1, 0.5774, 1, 1, 0.7071}

 

Since the default for edgeflag is "shrink", the results are identical.

Remarks:

MOVSTD computes a centered moving standard deviation by centering the result within the N-point sliding segments. The output length is the same as the input length.

 

For each section of length N, the sample standard deviation value (dof == 0) is defined as:

 

sample standard deviation

 

where the arithmetic mean is defined as:

 

mean

 

The population standard deviation (dof == 1) is defined as:

 

population standard deviation

 

NaN values are included by default. Set naflag to "omitnan" to ignore NaN values.

 

For edgeflag == "discard", only segments that contain exactly N samples are processed. Shorter segments at the start and end edges are discarded.

 

See MOVSTDEV to compute a non-centered moving standard deviation.

 

See XMOVSTD to compute the centered moving standard deviation given a duration.

See Also:

MOVAVG

MOVRMS

MOVSTDEV

MOVVAR

STD

STDEV

XMOVSTD