awk script for finding probability of distribution of numbers


 
Thread Tools Search this Thread
Top Forums Programming awk script for finding probability of distribution of numbers
# 1  
Old 01-08-2013
awk script for finding probability of distribution of numbers

Dear All

I am having data file containing 0 to 40,000 like this...

Code:
0 5
1 65
2 159
3 356
...
...
40000 19

I want to find the probability of distribution between the numbers. The second column values are angles from 0 to 360 and the 1st column is number of files.

I am expecting ouptu data like this:

Code:
angle  probability
 0-10   1
 10-20  0
upto 
 350-360 1

Kindly advice.

Many Thanks
Balaji

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by radoulov; 01-08-2013 at 11:15 AM..
# 2  
Old 01-08-2013
Code:
awk '{ S=int($2/BUCKET);

        if((MIN=="")||(S<MIN)) MIN=S
        if((MAX=="")||(S>MAX)) MAX=S;
        A[S]++;
        T++ }

END {
        for(N=MIN; N<=MAX; N++)
                printf("%d-%d %f\n", N*BUCKET, (N+1)*BUCKET, A[N]/T);
}' BUCKET=10 inputfile

# 3  
Old 01-08-2013
Dear Corona

It works.

Many Thanks
BalajiSmilie
This User Gave Thanks to bala06 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with awk script to get missing numbers in column 1

Hello to all, I have show below a file separated by commas. In first column has numbers where the last number is 13. 1,4 2,6 3,7 5,2 6,5 7,5 8,65 9,10 11,78 13,2 What I want to know is which numbers are missing from 1 to 13 (in this case 13 is last number in column 1). My real... (17 Replies)
Discussion started by: Ophiuchus
17 Replies

2. Shell Programming and Scripting

awk script - need help finding matching entries

I have a config file like below JOHN 1,5,6,7,4,999,222,666,555 KELLY 54,77,33 ABC 98,22,11 name and then comma separated unique values. In my code I will have a number eg: 6 and I want to find out matching name eg: JOHN How do i do ? Please advise. Thanks. (5 Replies)
Discussion started by: vegasluxor
5 Replies

3. Shell Programming and Scripting

Complex match of numbers between 2 files awk script

Hello to all, I hope some awk guru could help me. I have 2 input files: File1: Is the complete database File2: Contains some numbers which I want to compare File1: "NUMBERKEY","SERVICENAME","PARAMETERNAME","PARAMETERVALUE","ALTERNATENUMBERKEY"... (9 Replies)
Discussion started by: Ophiuchus
9 Replies

4. Shell Programming and Scripting

awk script to filter the numbers which are around the set value

Hi All, I have one sensor output(over the same) for a set value of 20. Time(in Sec), Data 1, 16 2, 20 3, 24 4, 22 5, 21 6, 20 7, 19.5 8, 20 9, 20.5 10, 20 11, 20 12, 19.5 Here we can see like after 5 sec of time the data value reaches to 20+-0.5 range. So I... (7 Replies)
Discussion started by: ks_reddy
7 Replies

5. Shell Programming and Scripting

finding distance between numbers

Hi, I have a file as ABC 1634230,1634284,1634349,1634468 1634272,1634301,1634356,1634534 What I want is to find distance between the numbers.. column 1 is the gene name and column 2 are starts and column 3 are their respective stops for the starts. So what I want is column 3 which has +1... (2 Replies)
Discussion started by: Diya123
2 Replies

6. Shell Programming and Scripting

finding lowest numbers

i want to basically get the lowest numbers from a list ... for example my input file is .... 1 2 3 6 7 8 9 10 11 13 Now i want to create a script or a one liner which i can use like this ... for example ..../getlowest 3 --> this gives me the next 3 lowest numbers which... (6 Replies)
Discussion started by: greycells
6 Replies

7. Shell Programming and Scripting

Finding occurences of numbers

I have two files The first file is in following format 5 937 8 1860 5 1 683 2 1 129 2 2 5 938 8 1122 5 1 20 520 4 1860 1851 1 5 939 8 1122 1124 1 20 521 4 5883 14 6 1860 1852 1 683 4 2 (5 Replies)
Discussion started by: stuggler
5 Replies

8. Shell Programming and Scripting

awk - calculation of probability density

Hi all! I have the following problem: I would like to calculate using awk a probability of appearing of a pair of numbers x and y. In other words how frequently do these numbers appear? In the case of only one integer number x ranged for example from 1 to 100 awk one liner has the form: awk... (4 Replies)
Discussion started by: jarowit
4 Replies

9. Shell Programming and Scripting

calculation using awk or shell script in between the numbers

file A E969K D223L E400L E34L file B predicted 3 1 250 251 500 501 1000 The output should be E969K 501 1000 D223L 1 250 E400L 251 500 E34L 1 250 I tried in this way (1 Reply)
Discussion started by: cdfd123
1 Replies

10. IP Networking

finding port numbers

hither! whatz the command to find which process is using a specific port number? for example, port 8082? (3 Replies)
Discussion started by: darkcastle
3 Replies
Login or Register to Ask a Question