Script:
~addons/finance/finexec/actuarialnonlifes/data_arrays.ijs
Contributor: William Szuch
Updated: 2022 6 25
Depend: nil
Definitions: loaded to locale base
Status: dev
Script source:
data_arrays.ijs
Tools for creating data arrays by data
codes.
For example incident by report arrays.
Indexing - this starts at: 0 or 0 0 etc
Make sure that data codes have been calculated on this basis
or adjusted prior to using array1, array2 etc.
Also make sure that data codes have been
determined as required,
Especially codes (indices) for periods.
See definition for dates codes outside the range of the array
dimensions.
Accident periods - start at ‘0’ (Usually
ROWS)
Report periods - start at ‘0’ (Usually COLUMNS)
Development periods -(Accident period - Report period) (Usually
COLUMNS)
Payment periods - start at ‘0’ (Usually COLUMNS)
Equations:
To Do
Definitions
|
D
|
darray, darray1, darray2, darray3, darray4, darray5, darray6, darray7, darray8, data_codes
|
|
I
|
index_sum_count
|
|
M
|
max
|
|
N
|
nubsum, nubsum_all, nubsum_code
|
|
max
|
m
|
Maximum value in a list
|
darray (dyad)
Form: explicit
Depend: nil
General development verb - useful for large data cases.
Data codes have been determined as required.
If the data code is not range of the array dimension then
an index error is generated.
This should be fixed and then development can be completed.
Data count is in the last dimemsion.
Syntax
(N)darray(D)
N = set array dimensions eg: 5 5 5 5 5 5 5 5 eg. 4 6 8 8 3 4 5 6 etc
D = matrix of data to be summarised of which data codes
are in the first #N columns and data. in the remaing columns.
Example
$ (5)darray(Z =: ? 10 1 $ 5)
1 5
$ (5)darray(Z =: ? 10 2 $ 5)
2 5
$ (5 5)darray(Z =: ? 100000 8 $ 5)
7 5 5
$ (5 5 10 10)darray(Z =: ? 100000 8 $ 5)
5 5 5 10 10
$ (5 5 10 10)darray(Z =: ? 10000000 10 $ 5) NB. Large data
7 5 5 10 10
darray1 (dyad)
Form: explicit
Depend: nil
Data codes have been determined as required.
If the data code is not range of the array dimension then
the data is not included.
No error is generated to show that the data code is not in the
range.
Data count is in the first column.
Sums are in other columns
Syntax
(N)darray1(D)
N = set array dimension eg: 5
D = matrix of data to be summarised of
which data codes are in the first column and data in
the remaining columns.
Example
$ (5)darray1( Z =: 0 + ? (10 2 $ 5))
5 2
$ (10)darray1( Z =: 0 + ? (30 3 $ 5))
10 3
darray2 (dyad)
Form: explicit
Depend: array1
Data codes have been determined as required.
If the data code is not range of the array dimension then
the data is not included.
No error is generated to show that the data code is not in the
range.
Data count is in the first table.
(N)darray2(D)
N = set array dimensions eg: 5 5 eg: 4 6 etc
D = matrix of data to be summarised of
which data codes are in the first two columns and data in
the remaining columns.
Example
$ (5 5)darray2(Z =: 0 + ? (10 4 $ 5))
3 5 5
darray3 (dyad)
Form: explicit
Depend: dev1
Data codes have been determined as required.
If the data code is not range of the array dimension then
the data is not included.
No error is generated to show that the data code is not in the
range.
Data count is in the first table.
Syntax
(N)darray3(D)
N = set matrix dimemsions eg: 5 5 5 eg: 4 6 8 etc
D = matrix of data to be summarised of
which data codes are in the first three columns and data in
the remaing columns.
Example
$ (5 5 5)darray3(Z =: 0 + ?(10 5 $ 5))
3 5 5 5
darray4 (dyad)
Form: explicit
Depend: dev1
Data codes have been determined as required.
If the data code is not range of the array dimension then
the data is not included.
No error is generated to show that the data code is not in the
range.
Data count is in the first table.
Syntax
(N)darray3(D)
N = set matrix dimensions eg: 5 5 5 5 eg: 4 4 6 8 etc
D = matrix of data to be summarised of
which data codes are in the first four columns and data in
in the remaining columns
Example
($ 5 5 5 5)darray4(Z =: 0 + ? 10 6 $ 5)
3 5 5 5 5
darray5 (dyad)
Form: explicit
Depend: dev1
Data codes have been determined as required.
If the data code is not range of the array dimension then
the data is not included.
No error is generated to show that the data code is not in the
range.
Data count is in the first table.
Syntax
(N)darray5(D)
N = set matrix dimensions eg: 5 5 5 5 5 eg. 4 4 4 6 8 etc
D = matrix of data to be summarised of
which data codes are in the first five columns and data in
in the remaining columns
Example
$ (5 5 5 5 5)darray5(Z =: 0 + ? 10 7 $ 5)
3 5 5 5 5 5
darray6 (dyad)
Form: explicit
Depend: dev1
Data codes have been determined as required.
If the data code is not range of the array dimension then
the data is not included.
No error is generated to show that the data code is not in the
range.
Data count is in the first table.
Syntax
(N)darray6(D)
N = set matrix dimensions eg: 5 5 5 5 5 5 eg. 4 4 4 4 6 8 etc
D = matrix of data to be summarised of
which data codes are in the first six columns and data in
in the remaining columns
Example
$ (5 5 5 5 5 5)darray6(Z =: 0 + ? 10 7 $ 5)
2 5 5 5 5 5 5
darray7 (dyad)
Form: explicit
Depend: dev1
Data codes have been determined as required.
If the data code is not range of the array dimension then
the data is not included.
No error is generated to show that the data code is not in the
range.
Data count is in the first table.
Syntax
(N)darray7(D)
N = set matrix dimensions eg: 5 5 5 5 5 5 5 eg. 4 4 4 4 4 6 8 etc
D = matrix of data to be summarised of
which data codes are in the first seven columns and data in
in the remaining columns
Example
$ (5 5 5 5 5 5 5)darray7( Z =: ? 10 9 $ 5)
3 5 5 5 5 5 5 5
darray8 (dyad)
Form: explicit
Depend: dev1
Data codes have been determined as required.
If the data code is not range of the array dimension then
the data is not included.
No error is generated to show that the data code is not in the
range.
Data count is in the first table.
Syntax
(N)darray8(D)
N = set matrix dimensions eg: 5 5 5 5 5 5 5 5 eg. 4 4 4 4 4 4 6 8 etc
D = matrix of data to be summarised of
which data codes are in the first eight columns and data in
in the remaining columns
Example
$ (5 5 5 5 5 5 5 5)darray8(Z =: ?10 10 $ 5)
3 5 5 5 5 5 5 5 5
data_codes (monad)
Form: explicit
Depend: sort
Get the data codes from raw data.
Result is a boxed table of an index and data codes.
Data codes are sorted.
Syntax
data_codes(D)
D = data codes: required to be a boxed list.
text or numeric
Example
data_codes <"0 'sadfhyerZZ'
data_codes <"0 [? 10 # 10
index_sum_count (dyad)
Form: explicit
Depend: nubsum_code,max
Create sum and count from tables of codes and data.
nubsum (dyad)
Form: explicit
Depend: nil
Produce totals for subgroups based on the nub of the group.
Data is a boxed matrix.
Syntax
(C)nubsum(D)
C = columns to determine the nub from data.
numeric and text
D = data to be boxed
columns remaining to be summed ie: numeric
Example
D =: <"0 (0,0,i.6),.(0 0 1 1 2 2 0 0 ),. 8 5 $1
0 nubsum D
0 1 nubsum D
0 1 2 nubsum D
D1 =: (<"0 'aabbcdef'),.D
0 nubsum D1
0 1 nubsum D1
D2 =: (<"0 'aghnmcde'),.D1
0 1 nubsum D2
0 1 2 nubsum D2
nubsum_all (dyad)
Form: explicit
Depend: nil
Nub sum by code for data.
Try to make faster.
Syntax
(C)nubsum_all(D)
C = vector of codes
D = Vector of values to be summed
Example
0 1 2 4 5 2 0 1 nubsum_all 1 2 3 4 5 6 7 8
0 8
1 10
2 9
4 4
5 5
ZZZZZ =: ? 100000 2 $ 10
sort (0{"1 ZZZZZ) nubsum_all (1{"1 ZZZZZ)
nubsum_code (dyad)
Form: explicit
Depend: nil
Sums for code - numerical data.
Syntax
(D)nubsum_code(C)
D = N x 2 matrix of index and data
C = code to be summed
Example
2 1 nubsum_code 2
1 0
ZZ =: 5 2 $ 2 1 3 2 0 1 3 12 2 99
ZZ nubsum_code 2
2 100
>ZZ & nubsum_code each (~. 0{"1 ZZ)
2 100
3 14
0 1
ZZZ =: 100000 2 $ 2 1 3 2 0 1 3 12 2 99
> ZZZ & nubsum_code each (~. 0{"1 ZZZ)
2 2000000
3 280000
0 20000
ZZZZ =: ? 100000 2 $ 1000
> ZZZZ & nubsum_code each (~. 0{"1 ZZZZ)