muscles

Aggregate functions

Functions that fold the rows of a group into one value. Names are case-insensitive. Parameters of a function go in a first pair of parentheses, as in quantile(0.9)(x). The combinators extend every function here.

NameArgumentsDescription
anyxReturns the first value met in a group.
anyLastxReturns the last value met in a group.
argMaxarg, valReturns arg from the row where val is largest.
argMinarg, valReturns arg from the row where val is smallest.
avgxReturns the arithmetic mean of a numeric column.
avgWeightedx, weightReturns the mean of a column weighted by a second column.
corrx, yReturns the Pearson correlation coefficient of two columns.
count[x]Counts rows, or the rows where the argument is not NULL.
covarPopx, yReturns the population covariance of two columns.
covarSampx, yReturns the sample covariance of two columns.
deltaSumxSums the increases between consecutive rows and ignores decreases.
entropyxReturns the Shannon entropy of the values of a group.
groupArrayxCollects the values of a group into an array.
groupBitAndxReturns the bitwise AND of all values of a group.
groupBitmapxCounts the distinct integers of a group with a bitmap.
groupBitOrxReturns the bitwise OR of all values of a group.
groupBitXorxReturns the bitwise XOR of all values of a group.
kolmogorovSmirnovTestvalue, sample_indexReturns the statistic and the p-value of the Kolmogorov-Smirnov test over two samples.
kurtPopxReturns the population kurtosis.
kurtSampxReturns the sample kurtosis.
mannWhitneyUTestvalue, sample_indexReturns the U statistic and the p-value of the Mann-Whitney test over two samples.
maxxReturns the largest value of a column.
maxMapkeys, valuesTakes the largest value for each key over the rows of a group.
medianxEstimates the median of a group with a t-digest sketch.
medianExactxReturns the exact median, taking the nearest rank.
medianExactInterpolatedxReturns the exact median, interpolating linearly between the two nearest values.
minxReturns the smallest value of a column.
minMapkeys, valuesTakes the smallest value for each key over the rows of a group.
quantile(level)(x)Estimates the quantile at the given level, between 0 and 1, of a group with a t-digest sketch. Without the parameter the level is 0.5.
quantileExact(level)(x)Returns an exact quantile, taking the nearest rank.
quantileExactInterpolated(level)(x)Returns an exact quantile, interpolating linearly between the two nearest values.
quantiles(level, ...)(x)Estimates several quantiles of a group at once with a t-digest sketch and returns them as an array. Without parameters the levels are 0.25, 0.5, 0.75, 0.9 and 0.99.
quantilesExact(level, ...)(x)Returns several exact quantiles as an array, taking the nearest rank.
quantilesExactInterpolated(level, ...)(x)Returns several exact quantiles as an array, interpolating linearly between the two nearest values.
retentioncond1, cond2, ...Returns an array that tells, for each later condition, whether it held in a row together with the first condition.
sequenceCounttimestamp, cond1, cond2, ...Counts the event chains of a group that match a pattern of conditions.
sequenceMatchtimestamp, cond1, cond2, ...Returns 1 when the events of a group match a pattern of conditions.
simpleLinearRegressionx, yFits a least-squares line and returns the slope and the intercept as an array.
skewPopxReturns the population skewness.
skewSampxReturns the sample skewness.
stddevPopxReturns the population standard deviation.
stddevSampxReturns the sample standard deviation.
stochasticLinearRegressiontarget, feature1, ...Trains a linear regression model with stochastic gradient descent and returns the weights as an array.
stochasticLogisticRegressiontarget, feature1, ...Trains a logistic regression model with stochastic gradient descent and returns the weights as an array.
studentTTestvalue, sample_indexReturns the t statistic and the p-value of Student's t-test over two samples.
sumxReturns the sum of a numeric column.
sumMapkeys, valuesSums the values for each key over the rows of a group.
topK(k)(x)Returns the k most frequent values of a group, counted approximately. Without the parameter k is 10.
uniqxEstimates the number of distinct values with a HyperLogLog sketch.
uniqExactxCounts the exact number of distinct values.
uniqUpToxCounts distinct values up to a limit and returns the limit plus one above it.
varPopxReturns the population variance.
varSampxReturns the sample variance.
welchTTestvalue, sample_indexReturns the t statistic and the p-value of Welch's t-test over two samples.
windowFunneltimestamp, cond1, cond2, ...Returns the longest chain of conditions that hold in order within a time window.