Sponsored Content
Top Forums Shell Programming and Scripting Calculating frequency of values within bins Post 302587302 by ctsgnb on Wednesday 4th of January 2012 12:52:12 PM
Old 01-04-2012
I am not going to draw your graph but regarding the calculation maybe this will help (i hope i did not missunderstood your requirements):

Code:
awk 'BEGIN{m=M=0}{A[$1]+=$2;++B[$1];m=($1<m)?$1:m;M=($1>M)?$1:M}END{for(i=m;i<M;i++) if (i in B) {print i"-"i+1": "B[i]+0,"values have their $1 in "i " and the sum of their $2 is "A[i]+0}}' yourfile

Code:
$ cat mytst
15 12.5
15 11.2
16 0.2
16 1.4
17 1.6
18 4.5
17 5.6
12 8.6
11 7.2
9  2.3
$ awk 'BEGIN{m=M=0}{A[$1]+=$2;++B[$1];m=($1<m)?$1:m;M=($1>M)?$1:M}END{for(i=m;i<=M;i++) if (i in B) {print i"-"i+1": "B[i]+0,"values have their $1 in "i " and the sum of their $2 is "A[i]+0}}' mytst
9-10: 1 values have their $1 in 9 and the sum of their $2 is 2.3
11-12: 1 values have their $1 in 11 and the sum of their $2 is 7.2
12-13: 1 values have their $1 in 12 and the sum of their $2 is 8.6
15-16: 2 values have their $1 in 15 and the sum of their $2 is 23.7
16-17: 2 values have their $1 in 16 and the sum of their $2 is 1.6
17-18: 2 values have their $1 in 17 and the sum of their $2 is 7.2
18-19: 1 values have their $1 in 18 and the sum of their $2 is 4.5


Last edited by ctsgnb; 01-04-2012 at 02:14 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Calculating the Hours between two time values

Dear Folks, I want to calculate the elapsed hours between two time columns. I am using timestampdiff method for the same. I am able to get the value. But facing an issue of decimal values. For example the elapsed hours between 09:00:00 and 20:30:00 is coming as 11 instead of 11.5. I am using below... (1 Reply)
Discussion started by: dinesh1985
1 Replies

2. Shell Programming and Scripting

Calculating cumulative frequency

Hi, I have a file containing the frequency's of an element sorted in ascending order. The file looks something like this: #Element Frequency 1 1 2 1 3 1 4 1 5 1 6 ... (5 Replies)
Discussion started by: sajal.bhatia
5 Replies

3. Shell Programming and Scripting

Help with calculating frequency of specific word in a string

Input file: #read_1 AWEAWQQRZZZQWQQWZ #read_2 ZZAQWRQTWQQQWADSADZZZ #read_3 POGZZZZZZADWRR . . Desired output file: #read_1 3 #read_1 1 #read_2 2 #read_2 3 #read_3 6 . . (3 Replies)
Discussion started by: perl_beginner
3 Replies

4. Solaris

Redirecting print to optional output bins

Guys We have a HP P4015 laserjet printer with a 5 bin mailbox attached & configured. We can print to the specific output bins from Oracle e-Business suite, however our print output format is incompatible so it prints out random characters instead of the letter content. I have looked... (2 Replies)
Discussion started by: s1977
2 Replies

5. Shell Programming and Scripting

calculating unique strings values

Hi, Im looking for a script which will calculate the unique strings column 2 & 3 values in a log as mentioned in example eg:- bag 12 12 bag 18 15 bags 15 13 bags 15 14 blazer 24 24 blazer 33 32 boots 19 15 Result should be:- bag 30 27 bags 30 27... (9 Replies)
Discussion started by: Paulwintech
9 Replies

6. UNIX for Dummies Questions & Answers

Calculating cumulative frequency using awk

Hi, I wanted to calculate cumulative frequency distribution of my data that involves several arithmetic calls. I did things in excel but its taking me forever. this is what I want to do: var1.txt contains n observations which I have to compute for frequency which is given by 1/n and subsequently... (7 Replies)
Discussion started by: ida1215
7 Replies

7. UNIX for Dummies Questions & Answers

awk solution for taking bins

Hi all, I'm looking for an awk solution for taking bins of data set. For example, if I have two columns of data that I wish to use for a scatter plot, and it contains 5 million lines, how can I take averages of every 100 points, 1000, 10000 etc... The idea is to take bins of the 5,000,000 points... (7 Replies)
Discussion started by: torchij
7 Replies

8. Shell Programming and Scripting

Count frequency of unique values in specific column

Hi, I have tab-deliminated data similar to the following: dot is-big 2 dot is-round 3 dot is-gray 4 cat is-big 3 hot in-summer 5 I want to count the frequency of each individual "unique" value in the 1st column. Thus, the desired output would be as follows: dot 3 cat 1 hot 1 is... (5 Replies)
Discussion started by: owwow14
5 Replies

9. Shell Programming and Scripting

awk to select 2D data bins

I wish to use AWK to do something akin: Select all 2D data with 1<$1<2 and -7.5<$2<-6.5 But it's not working awk 'END {print ($1<=2&&$1>=1&&$2<=-6.5&&$2>=-7.5)}' bla Data: -1.06897 -8.04482 -61.469 -1.13613 -8.04482 -61.2271 -1.00182 -8.04482 -61.2081 -1.06897 -8.13518 -60.8544... (2 Replies)
Discussion started by: chrisjorg
2 Replies

10. UNIX for Beginners Questions & Answers

Create bins with totals and percentage

I would like to create bins to get histogram with totals and percentage, e.g. starting from 0. If possible to set the minimum and maximum value in the bins ( in my case value min=0 and max=20 ) Input file 8 5 10 1 11 4 12 4 12 4 13 5 16 7 18 9 16 9 17 7 18 5 19 5 20 1 21 7 (10 Replies)
Discussion started by: jiam912
10 Replies
GR_PLOT_FFT_C(1)						   User Commands						  GR_PLOT_FFT_C(1)

NAME
gr_plot_fft_c - plot complex binary data using GNU Radio SYNOPSIS
gr_plot_fft_c: [options] input_filename DESCRIPTION
Takes a GNU Radio complex binary file and displays the I&Q data versus time as well as the frequency domain (FFT) plot. The y-axis values are plotted assuming volts as the amplitude of the I&Q streams and converted into dBm in the frequency domain (the 1/N power adjustment out of the FFT is performed internally). The script plots a certain block of data at a time, specified on the command line as -B or --block. This value defaults to 1000. The start position in the file can be set by specifying -s or --start and defaults to 0 (the start of the file). By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time and frequency axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples. OPTIONS
-h, --help show this help message and exit -B BLOCK, --block=BLOCK Specify the block size [default=1000] -s START, --start=START Specify where to start in the file [default=0] -R SAMPLE_RATE, --sample-rate=SAMPLE_RATE Set the sampler rate of the data [default=1.0] SEE ALSO
gr_plot_char(1) gr_plot_const(1) gr_plot_fft_c(1) gr_plot_fft_f(1) gr_plot_float(1) gr_plot_int(1) gr_plot_iq(1) gr_plot_psd_c(1) gr_plot_psd_f(1) gr_plot_qt(1) gr_plot_short(1) gr_plot_fft_c 3.5 December 2011 GR_PLOT_FFT_C(1)
All times are GMT -4. The time now is 08:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy