max

max, function

def nosort process max(value: _typ): _typ
def const dash autodiff pure max(a: number, b: number): number
def pure max(r: ranvar, n: number): ranvar
def pure max(n: number, r: ranvar): ranvar
def pure max(r1: ranvar, r2: ranvar): ranvar
def pure max(z: zedfunc, n: number): zedfunc
def pure max(n: number, z: zedfunc): zedfunc
def pure max(z1: zedfunc, z2: zedfunc): zedfunc

Returns the largest value in a group, or the pointwise maximum for numbers, ranvars, or zedfuncs.

Examples

table T = with
  [| as Group, as Value |]
  [| "A", 2 |]
  [| "A", 5 |]
  [| "B", 4 |]
  [| "B", 3 |]

table G[g] = by T.Group
G.Max = max(T.Value)

show table "Maximum" with
  g as "Group"
  G.Max as "Max"

This produces the following table:

Group Max
A 5
B 4
show table "Max value" with
  max(1, 2, 3) as "Value"

This produces the following table:

Value
3
r1 = poisson(1)
r2 = poisson(3)

show table "Max ranvar" with
  mean(max(r1, r2)) as "Mean"

This produces the following table:

Mean
3.133489

Remarks

The numeric overload is variadic. Empty groups return the default value for the data type.

User Contributed Notes
0 notes + add a note