WindowedSum

From VLECK
Jump to: navigation, search

Returns the means of groups of values of set size �


Syntax

Result = WindowedSum(Values1;NumberToSum, Offset= 0 ; PivotDim = -1 ;PivotDim = -1 );


Return Value

WindowedSum() returns the summed elements over the preset window (=number of elements to sum). The return matrix is of the same shape as the first argument. If the offset is zero, the first element is the sum of the first n (n = number of elements to sum) elements, the second element is the sum of elements 2 to n+1 etc with the last elements "incomplete" sums as there are not enough elements left. If there is an offset, this is equal to the number of "incomplete" sums added before the sum of the first n elements, which means there are less "incomplete" sums at the end of the row of values. As the number of incomplete sums cannot be higher than the number of elements to sum, the actual offset is the modulus of the value for offset and the number of elements to sum. �


Parameters

Values1 matrix or structure with numerical values over which mean is to be taken
NumberToSum single value determining over how many elements the sum is take in Values1
Offset single value determining how many elements are shown before the first "full" sum of values as determined by NumberToSum. If this value is larger than NumberToSum , the modulus of Offset and NumberToSum is taken . If not specified, Offset is zero.
PivotDim1 one single integer value assigning the pivotal dimension of Values1 . If not specified, the last dimension is the pivotal dimension. �
PivotDim2 one single integer value assigning the pivotal dimension of Values2 . If not specified, the last dimension is the pivotal dimension. �

Example


A = 1#10

A = 1#10

1 2 3 4 5 6 7 8 9 10

R=WindowedSum(A;2; -1;-1)

R=WindowedSum(A;2,0; -1;-1)

3 5 7 9 11 13 15 17 19 10

R=WindowedSum(A;3,0; -1;-1)

R=WindowedSum(A;3,0; -1;-1)

6 9 12 15 18 21 24 27 19 10

R=WindowedSum(A;4,0; -1;-1)

R=WindowedSum(A;4,0; -1;-1)

10 14 18 22 26 30 34 27 19 10

R=WindowedSum(A;4,1; -1;-1)

R=WindowedSum(A;4,1; -1;-1)

6 10 14 18 22 26 30 34 27 19

R=WindowedSum(A;4,2; -1;-1)

R=WindowedSum(A;4,2; -1;-1)

3 6 10 14 18 22 26 30 34 27

R=WindowedSum(A;4,6; -1;-1)

R=WindowedSum(A;4,6; -1;-1)

3 6 10 14 18 22 26 30 34 27

Example


A=Redim(1#20;4,5)

A=Redim(1#20;4,5)

1 2 3 4 5

6 7 8 9 10

11 12 13 14 15

16 17 18 19 20

R=WindowedSum(A;2; 1;-1)

R=WindowedSum(A;2; 1)

7 9 11 13 15

17 19 21 23 25

27 29 31 33 35

16 17 18 19 20

R=WindowedSum(A;2; -1;-1)

R=WindowedSum(A;2; -1;-1)

3 5 7 9 5

13 15 17 19 10

23 25 27 29 15

33 35 37 39 20