Skip to main content
Version: v1.15.0

avg

Aggregate Function

avg average value

Synopsis

avg(number) -> number

Description

The avg aggregate function computes the mathematical average value of its input.

Examples

Average value of simple sequence:

echo '1 2 3 4' | zq -z 'avg(this)' -

=>

2.5

Continuous average of simple sequence:

echo '1 2 3 4' | zq -z 'yield avg(this)' -

=>

1.
1.5
2.
2.5

Unrecognized types are ignored:

echo '1 2 3 4 "foo"' | zq -z 'avg(this)' -

=>

2.5