Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Search Forums:



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-10-2008
Registered User
 

Join Date: Nov 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
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 using AWK)

Anyone can help me...Please..

Thanks
Sponsored Links
    #2  
Old 12-09-2008
Registered User
 

Join Date: Dec 2008
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
unix calculator

Hi,

I would like to know how can I calculate mean, median and standard deviation of some numbers in a file.

Example file:
a 102 abc
b 301 adc
c 222 adc

I would like to calculate the mean, median and standard deviation of the numbers in the 2nd column of the example file.

Thanks in advance
Sponsored Links
    #3  
Old 12-09-2008
BubbaJoe's Avatar
Registered User
 

Join Date: Oct 2008
Location: St Louis
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Maybe you should use awk instead of calculator to get the results. It would be much easier to grab the 2nd field an do the math on those.
    #4  
Old 12-09-2008
vidyadhar85's Avatar
Moderator(The Tutor)
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,518
Thanks: 0
Thanked 5 Times in 5 Posts
this will find the mean of numbers

Code:
awk '{mean += $2}END{print "mean ="mean/NR}' filename


Last edited by otheus; 01-30-2009 at 04:25 AM.. Reason: Corrected equation for mean
Sponsored Links
    #5  
Old 01-30-2009
otheus's Avatar
otheus otheus is offline Forum Advisor  
Smartass
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 2,124
Thanks: 11
Thanked 34 Times in 33 Posts
For the median, you can the answer in this post to your problem. In this case, you will want to change "$NF" to "$2".
Sponsored Links
Closed Thread

Tags
average, median, statistical calculator

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How To Calculate krishna_sicsr Shell Programming and Scripting 3 03-21-2009 12:49 PM
calculate the space za_7565 Shell Programming and Scripting 8 05-04-2008 07:22 AM
calculate time itik AIX 2 02-15-2008 01:08 AM
calculate from three files koti_rama Shell Programming and Scripting 5 01-08-2008 08:27 AM
How to calculate with awk whatisthis Shell Programming and Scripting 4 11-09-2005 11:39 AM



All times are GMT -4. The time now is 05:17 AM.