aboutsummaryrefslogtreecommitdiff
path: root/bin/mode.awk
blob: e43de98e5ea10007758cb4afa2a86262bc6a80b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
# Get mode of a list of numbers
# If the distribution is multimodal, the first mode is used
{ vals[$1]++ }
END {
    # Error out if we read no values at all
    if (!NR)
        exit(1)
    mode = vals[0]
    for (val in vals)
        if (vals[val] > vals[mode])
            mode = val
    print mode
}