def nosort autodiff process avg(a: number): number
def nosort process avg(a: i64): i64
def nosort process avg(a: f64): f64
Returns the numerical average of the grouped numbers in a. For empty groups, it returns 0.
a: the numbers to average.
Examples
table T = with
[| as A, as B |]
[| 0, "a" |]
[| 0, "a" |]
[| 0, "b" |]
[| 1, "b" |]
[| 1, "c" |]
table G[gdim] = by T.B
show table "Average by group" with
gdim
avg(T.A)
group by gdim
Output:
gdim
avg(T.A)
a
0
b
0.5
c
1
Remarks
The number overload is usable in autodiff contexts.