Rolling Statistics

Use the Database Tools > Filters > Rolling Statistics menu option (ROLLINGSTATS GX) to calculate statistics on the values in a window surrounding individual data points.

The option is also available in the Moving Platform Gravity > 1D Filters menu.

Rolling Statistics dialog options

Channel to analyze

From the list of channels in the current database, select the channel to analyze.

Script Parameter: ROLLINGSTATS.IN

Output statistics channel

Specify the output channel that will contain the results (it will be created if it does not exist).

Script Parameter: ROLLINGSTATS.OUT

Statistic to calculate

Select one of the available methods from the drop-down list. See the table below (in the Application Notes section) for the list of available statistics.

Script Parameter: ROLLINGSTATS.STATISTIC – See the table below.

Window width

Specify the width of the rolling window. If this value is even, it is increased by 1 to obtain a window that is symmetric about each data point.

Script Parameter: ROLLINGSTATS.WIDTH

Shrink window at ends

Choose whether to shrink window at ends. If "Yes" is selected, the window shrinks near the ends so that it remains of equal size on both sides of the individual data points. This can eliminate edge effects.

Script Parameter: ROLLINGSTATS.SHRINK 0:No, 1:Yes

Application Notes

If the window size is even, it is increased by 1 so that the output value is put at the exact centre index of the window.

Statistics are calculated on the values in a window surrounding the individual data points.

By shrinking the window at the ends, one-sided effects can be eliminated. For instance, if the data is linear to begin with, a rolling mean will not alter the original data. However, if the window size is kept constant, values near the ends tend to be pulled up or down.

With shrinking, the window is shrunk so that it always has the same width on both sides of the data point under analysis; at the end points the window width is 1, at the next point in it is 3, and so on, until the full width is reached.

The median value is calculated by sorting the valid data in the window, then selecting the middle value. If the number of valid data points is even, then the average of the two central values is returned.

The mode value is defined as the value that occurs most frequently in the data. This value may not even exist, or may not be unique.

In this implementation, the following algorithm is used:

  1. The valid data in the window is sorted in ascending order.
  2. The number of occurrences of each data value is tracked, and if it occurs more times than any value, it becomes the modal value.
  3. If all values are different, this procedure returns the smallest value.
  4. If two or more values each have the same (maximum) number of occurrences, then the smallest of these values is returned.
The following statistics are supported:

Statistic

Explanation

Script value

Number of items

Total items – dummy items

0

Items > 0

Positive items

1

Dummy values

 

2

Minimum

Minimum value

3

Maximum

Maximum value

4

Range

Maximum - minimum

5

Mean

Sum / Valid items

6

Median

Middle of sorted values (See note above)

7

Mode

Most frequently occurring value (See note above)

8

Geometric Mean

Uses only positive values.

9

Variance

 

10

Standard Deviation

 

11

Standard Error

 

12

Skew

Normalized 3rd moment

13

Kurtosis

Normalized 4th moment

14

First value

Base (1st) value in the window

15

Sum

 

16

Sum of squares

 

17

Sum of cubes

 

18

Sum of 4th powers

 

19