Help with calculate median, first quartile, second quartile and third quartile

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with calculate median, first quartile, second quartile and third quartile
# 8  
Old 06-06-2011
this is what are you looking for ?
awk 'NR%4==0' filename

# 9  
Old 06-06-2011
Hi kumaran_5555,

Thanks for your script.
I thought it should be Q1= 8.6, Q2=12.2, Q3=20.65 instead of Q1= 12.2, Q2=8.6, Q3=20.65?
Thanks for verification.
# 10  
Old 06-06-2011
I have just edited the script, can you check now
# 11  
Old 06-06-2011
awk 'NR==FNR{Q1=int((NR+1)/4);Q2=int((NR+1)/2);Q3=int((NR+1)*3/4);next}
     FNR==Q1||FNR==Q2||FNR==Q3 ' infile <(sort -n infile)

This User Gave Thanks to rdcwayx For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Median calculator based on id match

I am trying to calculate the median of a column of numbers if they match an ID type on a different column. The input file has 3 columns. The column that has the ID is column 1 and the column with the values I'd like to find the median for is column 3. The file does not need to be sorted. What I... (9 Replies)
Discussion started by: verse123
9 Replies

2. Shell Programming and Scripting

Median and max of duplicate rows

Hi all, plz help me with this, I want to to extract the duplicate rows (column 1) in a file which at least repeat 4 times. then I want to summarize them by getting the max , mean, median and min. The file is sorted by column 1, all the repeated rows appear together. If number of elements is... (5 Replies)
Discussion started by: ritakadm
5 Replies

3. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

4. UNIX for Dummies Questions & Answers

Help with Median

Hi, I know this question has been asked before, but I'd like to ask for some explanation rather than solution regarding finding median in unix. I've got a simple one column file with over 2 million numbers and I need to find its median. The file looks like this: 0.123 0.235 0.890 0.000 etc... (11 Replies)
Discussion started by: zajtat
11 Replies

5. UNIX for Dummies Questions & Answers

Calculate the Median, first quartile and third quartile using AWK

Hi all, I have a data range as follow: 28 33 42 12 9 68 81 55 6 47 Since I want to create Box & Whisker Plot, I need to calculate the median, first quartile and third quartile of above data using AWK.( so far I can only writing a code for determine smallest value & largest value... (4 Replies)
Discussion started by: nica
4 Replies

6. Shell Programming and Scripting

awk to median

hi! i have a file like the attachement. you can see on the last column, there is a marker from 1 to 64 for each time. I'd like to have the median for each marker: i want to get a median every 128 values the result is : for an hour and marker x, i have the median value thank you for... (5 Replies)
Discussion started by: riderman
5 Replies
Login or Register to Ask a Question