Aggregations#
Catalogue#
Aggregation catalogue#
The aggregations, one row each. A cursor is a series cursor, and T the type of the slot it reads. The builtins page’s columns apply.
Name |
Arities |
Tier |
Signature |
Summary |
Defined by |
|---|---|---|---|---|---|
|
2 |
pure |
(cursor, value: T) → Bool |
Whether the value is among the series’ samples in its window. |
|
|
1 |
pure |
(cursor) → Int |
Number of samples in the series’ window. |
|
|
1 |
pure |
(cursor) → Int |
Number of distinct sample values in the series’ window. |
|
|
2 |
pure |
(cursor, value: T) → Int |
Number of samples in the series’ window equal to the value. |
|
|
1 |
pure |
(cursor) → Int? |
Sign of the difference of the two newest samples: −1, 0 or 1. |
|
|
1 |
pure |
(cursor) → Float? |
Arithmetic mean of the series’ window. |
|
|
1 |
pure |
(cursor) → Float? |
Median of the series’ window, as p50. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 1 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 2 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 3 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 4 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 5 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 6 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 7 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 8 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 9 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 10 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 11 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 12 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 13 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 14 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 15 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 16 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 17 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 18 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 19 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 20 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 21 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 22 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 23 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 24 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 25 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 26 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 27 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 28 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 29 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 30 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 31 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 32 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 33 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 34 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 35 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 36 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 37 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 38 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 39 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 40 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 41 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 42 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 43 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 44 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 45 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 46 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 47 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 48 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 49 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 50 of the series’ window, interpolated; the median. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 51 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 52 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 53 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 54 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 55 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 56 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 57 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 58 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 59 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 60 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 61 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 62 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 63 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 64 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 65 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 66 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 67 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 68 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 69 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 70 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 71 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 72 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 73 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 74 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 75 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 76 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 77 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 78 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 79 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 80 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 81 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 82 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 83 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 84 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 85 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 86 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 87 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 88 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 89 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 90 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 91 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 92 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 93 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 94 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 95 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 96 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 97 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 98 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Percentile 99 of the series’ window, interpolated. |
|
|
1 |
pure |
(cursor) → Float? |
Population standard deviation of the series’ window. |
|
|
1 |
pure |
(cursor) → Float? |
Population variance of the series’ window. |
|
|
1 |
pure |
(cursor) → Float? |
(last − first) / elapsed seconds over the series’ window. |
|
|
1 |
pure |
(cursor) → Float? |
Sample standard deviation of the series’ window. |
|
|
1 |
pure |
(cursor) → Float? |
Sample variance of the series’ window. |
Applicability#
An aggregation whose type does not match the slot’s is refused with DS_VALIDATE_SERIES_AGG_TYPE_MISMATCH.
Aggregation |
Slot value types |
Returns |
|---|---|---|
|
|
the slot’s type, nullable |
|
|
the slot’s type |
|
|
|
|
any type |
|
|
any type with defined equality |
|
|
any type with defined equality |
|
|
|
|
|
any type |
the slot’s type, nullable |
|
|
|
|
|
|
Returns is the static type of both call forms. String and Bytes slots admit count, count_distinct, count_of, contains, first and last. A Json slot admits count, first and last. Type and time model are two axes, both to be met, and the compiler reports the first that fails. Signal aggregations have their own table.
Refused with DS_VALIDATE_SERIES_AGG_TYPE_MISMATCH
series Reading.label:
mean sliding 10_min
(Spec: [LSER.17.1], [LSER.17.2], [LSER.17.3], [LSER.17.4], [LSER.17.5], [LSER.17.7], Source: compiler/mercury/src/dsc.series.m)
Name refusals#
Condition |
Code |
|---|---|
a name that is no aggregation |
|
|
|
Refused with DS_VALIDATE_SERIES_INVALID_QUANTILE
series Reading.level:
p100 sliding 10_min
(Spec: [LSER.16.4.1], [LSER.17.6], [LSER.18.1])
Vocabulary#
Descriptive statistics#
Aggregation |
Answers |
|---|---|
|
the arithmetic mean |
|
the 50th percentile, as |
|
the minimum, the maximum |
|
the sum |
|
the sample count |
sum over an Int slot accumulates in a 64-bit signed integer, and wraps as Int does.
(Spec: [LSER.16.2], [LSER.16.2.2], [LSER.16.4.2])
Dispersion#
Aggregation |
Answers |
At one sample |
|---|---|---|
|
the sample standard deviation |
|
|
the population standard deviation |
|
|
the sample variance |
|
|
the population variance |
|
(Spec: [LSER.16.3.1], [LSER.16.3.3])
Quantiles#
pXX
pXX interpolates linearly between the two order statistics that bracket it, for an integer XX in 1..99.
The window’s n samples sort ascending as Float, an Int converting round-to-nearest-even and -0 before +0, as x_0 .. x_{n-1}. With num = (n-1) * XX, lo = num // 100 and frac = num % 100, the result is x_lo when frac = 0, when x_lo = x_{lo+1}, or when x_lo is -inf and x_{lo+1} is not +inf. Otherwise it is x_lo + (frac / 100) * (x_{lo+1} - x_lo), evaluated as correctly rounded operations in the order subtraction, division, multiplication, addition. With n = 1 it is x_0. A bracketing pair of -inf and +inf reads NaN.
(Spec: [LSER.16.4.1], [LSER.17.2])
Cardinality and membership#
Aggregation |
Answers |
|---|---|
|
the count of distinct values |
|
the count of |
|
whether |
count_distinct(r)
count_of(r, 1.0)
contains(r, 1.0)
(Spec: [LSER.16.5.1], [LSER.16.6.1], [LSER.16.7.1])
Boolean aggregations#
Aggregation |
Answers |
|---|---|
|
whether every sample is true |
|
whether any sample is true |
(Spec: [LSER.16.8], [LSER.16.8.1])
Temporal aggregations#
Aggregation |
Answers |
Also |
|---|---|---|
|
the oldest sample’s value |
|
|
the newest sample’s value |
|
|
|
no time elapses between the first and last samples |
|
|
the window holds one sample |
direction is the sign of the two newest samples’ difference, decided by comparing them, with no tolerance. -0 and +0 compare equal. null while cold is Cold read.
r.first
r.last
r.rate
r.direction
(Spec: [LSER.10.9], [LSER.16.9], [LSER.16.9.1])
Computation order#
sum, mean and the dispersion statistics are computed in one order per time model, each step one correctly rounded binary64 operation.
Samples x_1 .. x_n are Float, an Int converting round-to-nearest-even; an Int slot’s sum is the integer sum.
Time model |
Sample order |
State |
|---|---|---|
|
arrival |
|
|
live samples, oldest first |
two passes |
|
slots |
|
sum:S_0 = +0,S_k = S_{k-1} + x_k.all_time,sample:d = x_k - mu_{k-1},mu_k = mu_{k-1} + d / k,M_k = M_{k-1} + d * (x_k - mu_k).meanismu_n, andMisM_n.sliding:meanismu = S_n / n.Q_0 = +0,d = x_k - mu,Q_k = Q_{k-1} + d * d, andMisQ_n.Every time model:
varianceisM / (n - 1),pvarianceisM / n,stdevandpstdevtheir square roots. Onall_timeandsliding, a variance not greater than0gives a deviation of+0.
(Spec: [LSER.16.3.3])
Result units#
Unit-preserving aggregations#
min, max, mean, median, pXX, stdev, pstdev, sum, first and last return the series slot’s unit, with no annotation.
count returns a dimensionless Int. Unit-typed slots states what such a slot holds.
integral result unit#
A let reading integral over a slot with a unit carries a type annotation naming a unit; one without is refused with DS_VALIDATE_DIM_AGG_UNANNOTATED.
Any unit symbol answers it. A read in a where, an emit slot or an interpolation needs none, and neither does a let over a slot with no unit or over onset_rate. integral’s Float return is its representation, and the annotation states its dimension.