Skip to content

Instantly share code, notes, and snippets.

@TakashiUNUMA
Created May 29, 2013 09:20
Show Gist options
  • Save TakashiUNUMA/5669033 to your computer and use it in GitHub Desktop.
Save TakashiUNUMA/5669033 to your computer and use it in GitHub Desktop.
Make a frequency distribution. USAGE: awk -f FREQ_DIST.awk [input_file]
#!/bin/awk -f
{
if(binsize <= 0) exit
if($1 < 0){
frequency[int($1 / binsize) - 1] ++
}else{
frequency[int($1 / binsize)] ++
}
}
END{
for(i in frequency){
printf("%10s %15.8f\n", i * binsize, (frequency[i]/NR)) | "sort -n"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment