Mathematics and statistics¶
| function | rank | ƒ | semantics |
|---|---|---|---|
+ |
2 | a | add |
- |
2 | a | subtract |
* |
2 | a | multiply |
% |
2 | a | divide |
$ |
2 | A | dot product, matrix multiply |
& |
2 | a | lesser |
| |
2 | a | greater |
abs |
1 | a | absolute value |
acos |
1 | a | arccosine |
asin |
1 | a | arcsine |
atan |
1 | a | arctangent |
avg |
1 | A | arithmetic mean |
avgs |
1 | u | arithmetic means |
ceiling |
1 | a | round up to integer |
cor |
2 | A | correlation |
cos |
1 | a | cosine |
cov |
2 | A | covariance |
deltas |
1 | u | differences |
dev |
1 | A | standard deviation |
div |
2 | a | integer division |
ema |
2 | m | exponential moving average |
exp |
1 | a | ex |
floor |
1 | a | round down to integer |
inv |
1 | u | matrix inverse |
log |
1 | a | natural logarithm |
lsq |
2 | matrix divide | |
mavg |
2 | m | moving average |
max |
1 | A | greatest |
maxs |
1 | u | maximums |
mcount |
2 | m | moving count |
mdev |
2 | m | moving deviation |
med |
1 | A | median |
min |
1 | A | least |
mins |
1 | u | minimums |
mmax |
2 | m | moving maximum |
mmin |
2 | m | moving minimum |
mmu |
2 | matrix multiply | |
mod |
2 | a | modulo |
msum |
2 | m | moving sum |
prd |
1 | A | product |
prds |
1 | u | products |
ratios |
1 | u | ratios |
reciprocal |
1 | a | reciprocal |
scov |
2 | A | statistical covariance |
sdev |
1 | A | statistical standard deviation |
signum |
1 | a | sign |
sin |
1 | a | sine |
sqrt |
1 | a | square root |
sum |
1 | A | sum |
sums |
1 | u | sums |
svar |
1 | A | statistical variance |
tan |
1 | a | tangent |
til |
1 | natural numbers till | |
var |
1 | A | variance |
wavg |
2 | A | weighted average |
wsum |
2 | A | weighted sum |
xbar |
2 | A | round down |
xexp |
2 | a | xy |
xlog |
2 | a | base-x logarithm of y |
ƒ – a: atomic; u: uniform; A: aggregate; m: moving
Domains and ranges¶
The domains and ranges of the mathematical functions have boolean, numeric, and temporal datatypes.
Individual function articles tabulate non-obvious domain and range datatypes.
Dictionaries and tables¶
The domains and ranges also extend to:
-
dictionaries where the
- simple tables where thevalueof the dictionary is in the domainvalueof theflipof the table is in the domain - keyed tables where thevalueof the table is in the domain
Exceptions to the above:
cor scov
cov sdev
dev svar
div (tables) til
ema var
inv wavg (tables)
lsq wsum (tables)
mmu xbar (tables)
mod (tables) xexp (tables)
Mathematics with temporals¶
Temporal datatypes (timestamp, month, date, datetime, timespan, minute, second, time) are encoded as integer or float offsets from 2000.01.01 or 00:00.
Mathematical functions on temporals are applied to the underlying numerics. See domain/range tables for individual functions for the result datatypes.
Beyond addition and subtraction
Results for addition and subtraction are generally intuitive and useful; not always for other arithmetic functions.
Aggregating nulls¶
avg, min, max and sum are special: they ignore nulls, in order to be similar to SQL92.
But for nested x these functions preserve the nulls.