Skip to content

sample_variance - Calculate the variance of an expression

The sample_variance command computes the variance of a given value. This is especially useful for answering the question "Is this value normal?".

NOTE: sample_variance is used when we only have a subset of data. For example, if we have heavy sampling on traces, we may wish to use the sample_variance rather than global variance, to be more statistically accurate.

Syntax

sample_variance(expression: number)

Arguments

Name Type Required Description
expression number true The expression for which we will find the sample variance

Example - Computing variance of duration in Traces

We can calculate the variance of the duration metadata field for a collection of traces, and group the results by operationName in the following way:

groupby $l.operationName aggregate sample_variance($m.duration)

This will let us know how much the duration of a given operationName varies over the specified timerange, when we don't have a complete dataset.