avg

Synopsis

double avg(NodeSet)
double avg(TupleSet, col)

Description

In its first form, sum computes the average of all numbers in a given set, and returns it as a double. Only numbers or strings that can be interpreted as numbers are counted; strings that cannot be parsed as a number are treated as having the value zero.

The second form of is command allows it to be applied to one column of an edge set or a tuple set. In this case, the first parameter specifies the data to work on, and the second parameter specifies the number of the column of interest (the numbering is zero-based).

Example

>> ints = {1,2,3,4}
>> floats={1.5, 2.5, 3.5, 4.5}
>> strings = {"aaa", "bbb", "ccc", "ddd"}
>> avg (ints)
2.5
>> avg (floats)
3.0
>> avg (strings)
0.0
>> avg ({})
NaN