g_linrecur(G;S;O;T;N;X;M;K)

Multivariate linear recurrence relations of arbitrary order

Syntax

g_linrecur(G;S;O;T;N;X;M;K)

Input

Argument Type Description
G any A space- or comma-separated list of column names

Rows are in the same group if their values for all of the columns listed in G are the same.

If G is omitted, all rows are considered to be in the same group.

If any of the columns listed in G contain N/A, the N/A value is considered a valid grouping value.

S integer The name of a column in which every row evaluates to a 1 or 0, which determines whether or not that row is selected to be included in the calculation

If S is omitted, all rows will be considered by the function (subject to any prior row selections).

If any of the values in S are neither 1 nor 0, an error is returned.

O integer A space- or comma-separated list of column names that determine the row order within a particular group

If O is omitted, the order is the current display order of the table.

If any of the values in O are N/A, an error is returned.

T integer A column name

T represents discrete time steps of the simulation.

If present, T must be (within each group) a non-decreasing sequence of integers greater than or equal to zero. For example: 1,2,3,4... or 0,1,4,5,5,6,7...
  • Contiguous values at each row represent single steps (e.g., 1,2,3)
  • Skipped values would lead to more than one step in the simulation (e.g., 1,4)
  • Repeated values would not step the simulation forward

If the sequence begins with a value less than the order of the relation (e.g., 0 for a first-order relation, 0 or 1 for a second-order, etc.), then the results for those times are copied from the seed values X.

If T is omitted, it defaults for each group to D, D+1, D+2, ... where D is the order of the relation.

N integer A scalar value

N is the number of variables in the relation.

X integer or decimal A space- or comma-separated list of either scalar values or column names

X denotes the starting values for the recurrence relation.

X is a list of D*N elements, where D is the order of the relation.

Each element is either a constant number or a numeric column. If it is a column, it should be the same for all values in the group (only the first value will be used).

The first N elements of X are the seed values for variables 1...N at time 0, the second N (in a second- or higher-order relation) for time 1, etc.

M integer or decimal A space- or comma-separated list of either scalar values or column names

M represents a list of coefficient matrices B(1) .. B(D).

M is a list of D*N*N elements, where D is the order of the relation.

Each element is either a constant number or a numeric column (in which case, the value at each row is used).

The first N*N values are B(1); the second (in a second- or higher-order relation) represent B(2), etc.

For an example, in the case of a second-order relation, two-variable relation, the list:

A1 A2 A3 A4 A5 A6 A7 A8

represents the two 2x2 matrices:

B(1)=

A1 A2
A3 A4

B(2)=

A5 A6
A7 A8
K integer or decimal A space- or comma-separated list of either scalar values or column names

K represents any constant terms in the recurrence relation. (optional)

If present, K must be a list of N elements, each of which is either a constant number or a numeric column (in which case, the value at each row is used).

If K is omitted, it is considered to be a list of N zeros.

Return Value

For every row in each group defined by G (and for those rows where S=1, if specified), g_linrecur returns a special type representing a vector for each row in the table.

A linear recurrence relation on N variables is computed for each group. The initial (seed) values for the relation are set by X, with the order of the relation being fixed by the number of elements in X, and at each time step (specified by T), the next value is calculated. The result of the function is a special vector type (N elements) that can be decomposed into the values of the individual variables with the select(V;I) function.

At time step T >= D, the vector value R of this function is:

B(1)*R(T-D) + B(2)*R(T-D+1) .. + B(D)*R(T-1) + K

where the products are matrix products of the matrices B and the earlier values R of the function.