Created
January 30, 2012 10:31
-
-
Save aont/1703769 to your computer and use it in GitHub Desktop.
awk histogram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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