Tables - zward/Amua GitHub Wiki
Tables can be defined to allow models to lookup a specific value or draw from an empirical distribution.
Entering Table Data
Table data can be entered manually or imported.
Manual
The table dimensions must be specified by adding/removing rows and columns using the '+'/'-' buttons. When adding a column you will be prompted to enter a column name. You can then type in the table values.
Import
Click the Import button
and select the .csv file to import. The table will automatically be resized to fit the imported data. The first row in the file will be used as table headers.
Paste
First select the table to copy in a spreadsheet (such as Excel), then click the Clipboard icon
to paste the selected data in an Amua table. The first row of data will be used as table headers.
Table Types
Lookup
A lookup table returns the value that corresponds to a particular index. The first column in a lookup table contains the table indices, and one or more columns of lookup values can be defined. Index values must be unique and in ascending order. There are 3 lookup methods:
- Exact: Returns the value associated with the exact index. If the exact index is not found the table returns
NaN. - Truncate: Returns a value that is truncated (i.e. floor) for the index. If the supplied index is below the minimum index the table returns
NaN. - Interpolate : Returns a value that is interpolated between indices. The following interpolation options are available:
- Linear: Linear interpolation between indices
- Cubic Splines: Fits piecewise cubic polynomials between indices. The following boundary conditions are available:
- Natural: Second derivative equals 0 at each boundary
- Clamped: First derivative equals 0 at each boundary
- Not-a-knot: Third derivative is continuous at knots 1 and n-1
- Periodic: First and second derivatives are equal at knots 0 and n
- Extrapolate: Option to extrapolate for supplied indices below/above the table indices
- No: Returned value is truncated at the min/max value in the table
- Yes: Table is extrapolated
- Left only: Table is extrapolated to the left only
- Right only: Table is extrapolated to the right only
Distribution
A distribution table allows the user to enter an empirical probability distribution. The first column in a distribution table contains the probability of each entry, and one or more columns of distribution values can be defined. The expected value of the selected column is calculated when you click 'Evaluate'. Probabilities must sum to 1.0.
Matrix
A matrix is a two-dimensional object of numbers. Matrix functions or operations can be performed on matrices.
Using a Table
Lookup Table
To get a value from a lookup table type the table name followed by comma-separated braces containing the lookup index and column number: [index,column]. Tables are 0-indexed, so the first column of values is 1 (since the indices are in column 0). Or you can enter the column name using single or double quotes: [index,"ColumnName"] or [index,'ColumnName'].
Lookup tables will turn orange in the formula bar.
Distribution Table
To return a value from an empirical distribution type the table name followed by parentheses specifying the column index of values from which to sample/return the expected value. The first column of values is 1. Or you can enter the column name using single or double quotes. Distribution tables will turn green in the formula bar. The PMF/CDF of the empirical distribution can also be evaluated - hover over the tablename in the formula bar for details.
Matrix
Matrix entries are referenced by [row, column] indices, starting from [0,0]. Matrix rows can be returned as a row vector by entering [row,:]. Similarly, columns can be returned as column vectors by entering [:,col].
Multiple cells can be returned by specifying a sequence of indices, for example [0:1, 1:2]. Matrices will turn purple in the formula bar.