My data looks like this:
frame phi psi
I would like to bin this data following the criteria of a bin for phi and psi values.
I.e. my desired output data would be of the form, if we
choose the bins to have width 10.
...
So, for an AWK script I need a command that will consider $2 and $3 in ranges of e.g. bin width 10:
e.g.
$2<=-170&&$2>=-180&&$3<=-170&&$3>=-180
$2<=-160&&$2>=-170&&$3<=-160&&$3>=-170
$2<=-150&&$2>=-160&&$3<=-150&&$3>=-160
$2<=-140&&$2>=-150&&$3<=-140&&$3>=-150
$2<=-130&&$2>=-140&&$3<=-130&&$3>=-140
$2<=-120&&$2>=-130&&$3<=-120&&$3>=-130
$2<=-110&&$2>=-120&&$3<=-110&&$3>=-120
$2<=-100&&$2>=-110&&$3<=-100&&$3>=-110
$2<=-90&&$2>=-100&&$3<=-90&&$3>=-100
...
and for each of these ranges, I wish to bin (count) the number of data points that fall within each interval. Any help here?
I can sort of see how to count in AWK, but how do you discretise the count in intervals of this kind. e.g how do you loop
with 10 units of change between each loop?
Thanks
Maybe it would simply be easier to simply bin the data like in this Perl script (which only works for binning 1-column arrays like Phi on its own: @list denotes the input array containing Phi, $bin_width is 10.
In this Perl script, we iterate over the hash using two variables called $key and $value. Consider the bin width 10. For an input data value of -173 we perform the ceiling calculation
ceil((-173+1)/10 - 1) =-18
This input number, -173, is located in bin -18 which is $key=-18 and has a $value=1. Then the next time the script locates a value in bin -18, it will augment (++) the $value to 2. etc. so we are binning the data in this way without requiring any selections. I would like to try to extend this script to a more complicated hash with 2 columns (one for phi, one for psi).
Anyway, maybe this helps?
The example output data is just an example of how it could look.
Fantastic, thanks.
What if I wanted to output bins that were not visited?
Currently I am only getting out bins that contain data, but
I would like to include bins that are not visited, is this possible?
In Perl, during the loop, if no data was accrued for a certain bin the
bin is still printed and the frequency is 0. ---------- Post updated at 01:31 PM ---------- Previous update was at 01:28 PM ----------
Currently my data is sort of useless when plotting:
Hello,
Since I m new to shell, I had a hard time to sought out this problem.
I have a log file of a utility which tells that batch files are successful with timestamp. Given below is a part of the log file.
2013/03/07 00:13:50 Apache/1.3.29 (Unix) configured -- resuming normal operations... (12 Replies)
I have a single file that looks like this:
1.62816
1.62816
0.86941
0.86941
0.731465
0.731465
1.03174
1.03174
0.769444
0.769444
0.981181
0.981181
1.14681
1.14681
1.00511
1.00511
1.20385
1.20385 (2 Replies)
I have a large tab delimited text file with 10 columns
for example
chrM 412 A A 75 0 25 2 ..,AGAATt II
chrM 413 G G 72 0 25 4 ..t,,Aag IIIH
chrM 414 C C 75 0 25 4 ...a,.. III2
chrM 415 C T 75 75 25 4 TTTt,,,ATC III7
At... (4 Replies)
Hi,
I want to perform a task using shell script. I am new to awk programming and any help would be greatly appreciated.
I have the following 3 files (for example)
file1:
Name count Symbol
chr1_1_50 10 XXXX
chr3_101_150 30 YYYY
File2:
Name ... (13 Replies)
I’m new to Linux script and not sure how to filter out bad records from huge flat files (over 1.3GB each). The delimiter is a semi colon “;”
Here is the sample of 5 lines in the file:
Name1;phone1;address1;city1;state1;zipcode1
Name2;phone2;address2;city2;state2;zipcode2;comment... (7 Replies)
Help plz
Does any one have any idea how to compare interval ranges of 2 files.
finding 1-4 (1,2,3,4) of input2 in input1 of same key "a" values (5-10, 30-40, 45-60, 80-90, 100-120 ). Obviously 1-4 is not one of the range with in input1 a. so it should give out of range.
finding 30-33(31,32,33)... (1 Reply)
I need "awk solution" for simple counting!
File looks like:
STUDENT GRADE
student1 A
student2 A
student3 B
student4 A
student5 B
Desired Output:
GRADE No.of Students
A 3
B 2
Thanks for awking! (4 Replies)
I want a shell script which extract data from a log file which contains date and time-wise data and i need the data for a perticular interval of time...what can i do??? (3 Replies)