aboutsummaryrefslogblamecommitdiff
path: root/bin/mode.awk
blob: 500fce2a0ccb3c2de48fa6a1df52ca993507320f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                           
              
 
# Get mode of a list of integers
# 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
}