Skip to content

Instantly share code, notes, and snippets.

@aont
Created January 30, 2012 10:31
Show Gist options
  • Select an option

  • Save aont/1703769 to your computer and use it in GitHub Desktop.

Select an option

Save aont/1703769 to your computer and use it in GitHub Desktop.
awk histogram
BEGIN {
range_min = 0.33
range_max = 0.48
range_size = range_max - range_min
num_bins = int(range_size/0.003)
bin_size = range_size / num_bins
for(i=0;i<num_bins;++i) {
freq[i] = 0
}
}
{
data = $2
if(data>range_min&&data<range_max) {
freq[int((data-range_min)/bin_size)]++
}
}
END {
for(i=0;i<num_bins;++i) {
print range_min+bin_size*(0.5+i), freq[i]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment