sum

sum, function

def nosort process sum(a: number): number
def nosort process sum(a: ranvar): ranvar
def nosort process sum(a: zedfunc): zedfunc

Returns the sum of a within each group.

Example

table T = with
  [| as A, as B |]
  [| 0, "a" |]
  [| 0.5, "a" |]
  [| 0, "b" |]
  [| 1, "b" |]
  [| 1, "c" |]

table G[gdim] = by T.B

show table "Sum by group" with
  gdim
  sum(T.A) as "Total"
  group by gdim

This outputs the following table:

gdim Total
a 0.5
b 1
c 1

Remarks

For ranvar and zedfunc inputs, the output is the sum of distributions or functions, respectively. Empty groups return 0, dirac(0), or constant(0) depending on the input type.

See also

User Contributed Notes
0 notes + add a note