Google Answers Logo
View Question
 
Q: finding the median ( Answered 4 out of 5 stars,   11 Comments )
Question  
Subject: finding the median
Category: Science > Math
Asked by: fishpond-ga
List Price: $8.00
Posted: 01 Jun 2002 14:19 PDT
Expires: 01 Jul 2002 14:19 PDT
Question ID: 20120
Is there some way to find the "median" of a large group of numbers,
without having to go through the tedious process of ranking them from
smallest to largest?
Answer  
Subject: Re: finding the median
Answered By: tehuti-ga on 01 Jun 2002 14:58 PDT
Rated:4 out of 5 stars
 
Hello,

You do not have to rank the numbers and look at which is the middle
one in the series.  If you can import the numbers into Excel, you can
use the MEDIAN() function of the software to find the median for you.

Get your numbers into a text file, with a line break between each, so
that you get a single column of data. The order of the numbers is not
important. Save the file.

Select "File, Open" in Excel and type in the name of your text file. 
An import wizard will come up and say that your file is delimited. 
Accept this, accept the rest of the defaults.  The file will be
imported into Excel as a single column of data, one number to each
row.

Type =MEDIAN( into any blank cell in the spreadsheet - do not close
the parentheses.
Use your mouse to select all the cells in the column of data.
Once you have selected the numbers, type in the second parenthesis in
the MEDIAN formula.  (Your selected range will already appear, and you
type in the parenthesis after this).
Press the Enter key, and you will see the median for your data
displayed in that cell.

You can find an example of how to do this, with illustrations at
http://www.farmresearch.com/ifafs/how/HDI-001e.htm

Being no Excel whizz-kid, I found this answer by searching on Google
using the terms "median", "calculate".  The retrieved pages are at
://www.google.com/search?q=median+calculate&hl=en&lr=&ie=UTF8&oe=UTF8&start=10&sa=N

Hope this helps
fishpond-ga rated this answer:4 out of 5 stars
Hello tehuti,

Thanks for your efforts.  (I tried that online median calculator you
suggested, and it does work with my ipaq ia-2 internet appliance, but
it would be laborious punching all those numbers in.)

Comments  
Subject: Re: finding the median
From: huntsman-ga on 01 Jun 2002 22:31 PDT
 
A few more tips.


Entering Excel's MEDIAN Function -

To avoid hand-typing errors, enter the MEDIAN (or any other) function
via Excel's menu commands:

1. Select the first empty cell at the bottom of your number column. 
2. Select the Insert > Function... menu command.
3. In the "Paste Function" dialog box, select the "Statistical"
category and its "MEDIAN" function. Click OK.
4. Another box opens showing the selected number range for the MEDIAN
function: make sure it's correct and click OK.
5. Your median value appears in the cell selected in Step 1 above. You
may want to format this cell with a different color or border so it's
easier to see.


Sorting the Number Range -

Excel's "MEDIAN" function sorts the selected range of numbers in the
background, then finds the median. The visible numbers in the selected
range stay in their original unsorted order.

Although it has no effect on the MEDIAN function, you may want to
visibly sort the numbers before or after you calculate the median:

1. Select the range of numbers.
2. Select the Data > Sort... menu command.
3. In the "Sort" box, the number column is listed under "Sort By".
Choose its "Ascending" option and click OK.
4. Your number range should be sorted from top to bottom.


If You Don't Have Excel -

You can also use shareware calculators with scrolling number "tapes"
and common statistical functions. My favorite is:

Judy's Ten Key Calculator
http://www.judysapps.com/TenKey.htm

Hope this helps,
huntsman
Subject: Re: finding the median
From: johnr-ga on 02 Jun 2002 12:40 PDT
 
The obvious way to find the median is to sort the numbers and pick the
middle one.  As the questioner observes, this is tedious. 
Furthermore, it has complexity n log n (for comparison-based sorting),
meaning that if you have large groups of numbers, the time taken grows
faster than the size of the group.

It's a classic computer-science problem to find an algorithm for the
median that avoids sorting and operates in linear expected time.  It
was first solved in 1972 by Blum, Floyd, Pratt, Rivest and Tarjan and
any introductory book on algorithms will describe the technique.  I
found some online lecture notes that give an introduction at
http://www.ics.uci.edu/~eppstein/161/syl.html (look at the lectures on
selection).
Subject: Re: finding the median
From: secret901-ga on 02 Jun 2002 16:00 PDT
 
What a horrible answer!  The person asked a question regarding finding
median in maths and got answers about Excel!!! Who cares what Excel
does?  Also, Excel's median function probably does have to look
through all the numbers as well!
Subject: Re: finding the median
From: tehuti-ga on 02 Jun 2002 16:38 PDT
 
secret901-ga's comment would have been more constructive if s/he had
also included references to another method to find the median.  Yes, I
did provide a method which uses Excel, because it is reasonable to
assume that a significant number of computer users do run this
software, or similar spreadsheet software with similar functionality,
as in e.g. Star Office.  The MEDIAN function in Excel does indeed sort
the numerical values in a way that is either visible or invisible to
the user.  The definition of the median is that it is the value which
occupies the central ranking in a series of an odd number of values
arranged in numerical order, or it is the mean of the two central
positions in a series of an even number of values.  Automatic sorting
of the data provides a rapid way to find the median.  fishpond-ga
requested a method which would eliminate the tedium of ranking data
manually; Excel provides a solution.  Of course, if fishpond-ga was
more interested in the mathematical theory or in researching how
computers could be applied to the problem, neither which were implied
in the question, then the comment of johnr-ga has provided a lead to
follow.
Subject: Re: finding the median
From: libraryman-ga on 03 Jun 2002 07:37 PDT
 
You didn't say how many separate numbers you were dealing with, that
has a bearing on the question. If you are dealing with, say, less than
40 or so numbers, then the Excel solution is ideal. If you're dealing
with many more than that, you might want to eliminate the obviously
highest and lowest numbers and input the middle range of numbers only.
That will APPROXIMATE the median.
I don't recall how to sort numbers using Excel (ranking them from
highest to lowest) but you could do that too with a truncated list. If
you are dealing with hundreds of numbers, then you've going to have to
deal with a whole lot of
typing numbers in, no alternative.
Subject: Re: finding the median
From: jeremymiles-ga on 03 Jun 2002 12:02 PDT
 
Everyone seems to be assuming that the numbers are stored in a
computer file already.  Given that the question didn't specify, I will
give an alternative answer, for a small number of possible numbers,
where there is no need to rank.

If the number of numbers in the set are limited (e.g. all the numbers
are whole numbers, from 1 to 10), and they are not in a computer,
create a stem and leaf plot, by going through the list, and ticking
off the numbers, each time they appear.

So the number set:  

3, 4, 2, 3, 4, 5, 1, 2, 3, 2, 1, 2, 3, 3, 3, 4, 3, 2, 3, 4, 5

Would look like:

1: xx
2: xxxxx
3: xxxxxxxx
4: xxxx
5: xx

Then count up the numbers

1: xx 2
2: xxxxx 5
3: xxxxxxxx 8
4: xxxx 4
5: x 2

Total: 21

Teh median is the 11th number. The 11th number is a 3 (1-2 are 1, 3-7
are 3, 8-15 are 3 ...)

I hope that might be some use.
Subject: Re: finding the median
From: fishpond-ga on 03 Jun 2002 12:13 PDT
 
I should have mentioned:

(1)  I'm dealing with hundreds of numbers.

(2)  I don't have a real computer, just an "ipaq home internet appliance ia-2."


Thanks, everyone, for your input.
Subject: Re: finding the median
From: jeremymiles-ga on 03 Jun 2002 14:54 PDT
 
If you've got hundreds of numbers, you can narrow it down, in a 2 step
way.

If the numbers are:

1.12, 4.23, 2.43, 9.56, etc, you can first just consider the 1st
number, and use the method I described above. Then you will know that
the number is (say) 4.xx, then do it again, for all of the 4.xx
numbers.

Afraid with hundreds, I don't know a shortcut that's not going to take
a while.
Subject: Re: finding the median
From: secret901-ga on 03 Jun 2002 16:24 PDT
 
Here's a method, adopted from a recursive algorithm, it is better done
by hand since humans can make guesses, whereas computers can't.
1)  Determine the number of items in your list of numbers, we'll call
that number T.  Now your job is to find the ceiling(T/2)th smallest
number in your list, call it N. (The ceiling function, as used in
computer science, means the smallest integer greater than a particular
number, e.g. in a list of size 13, you're looking for the 7th largest
number).  Remember if your original list has an even number of
elements, then you need to find 2 medians and take the mean between
them.
2)  Choose a number that you reasonably think is the median, we'll
call it the "pivot".  This guessing step can reduce a lot of time.
3)  Partition your list of numbers into 2 parts (ignoring your pivot):
one consisting of number less than or equal and the other consisting
of numbers greater than your guess.
4)  If the "less than" partition has a size equal to N-1, then you're
done.  (If your original list has an even number of elements, then
take the smallest element in your "greater than" list as well to get
the mean.)
5)  If not, here are what you can happen:
i) If (size of "smaller than" partition) >= N, discard the "greater
than" partition and repeat steps 2-5 with the "smaller than" partition
as the new list.
ii) Else repeat steps 2-5 with the "larger-than" partition as your
list and N - (size of "less than" partition) - 1 as your new N.

If you can keep track of your steps, then your final results would be
the median.

For example:
I have a list of numbers:
20, 10, 5, 15, 14, 20, 17, 4, 34, 34, 5.

First, I'm looking for the 6th largest number, N=6, since my size is
11.
Let's say that I guess that my median is 10.
Here's the two partitions for my list:
Less than: 5, 4, 5
Greater than: 20, 15, 14, 20, 17, 34, 34
Since my "less than" partition has a size of 3 != 5, I have to
continue.  Since (size of "less than" partition) < 6, I use the
"greater than" partition.  My N now becomes N-(size of "less than"
list)-1=6-3-1=2

This time, I guess that my median is 17
Less than: 15, 14
Greater than: 20, 20, 34, 34
Size of my "less than" list is 2 != 1, so I must continue. Since (size
of "less than" partition) >= N, I use the "less than" partition as my
new list.

Now the problem becomes a matter of finding the second smallest number
in the list  15, 14, which obviously is 15.

Check: Rearranging my numbers, I get:
4, 5, 5, 10, 14, 15, 17, 20, 20, 34, 34.
15 is my median.

This is more suited for computers, since one has to keep track of N's.
 But once you got the hang of it, you should be able to do it with
ease.  Also, you can cut up a lot of your work if you can guess your
median somewhat accurately.
Subject: Re: finding the median
From: tehuti-ga on 07 Jun 2002 09:39 PDT
 
I don't know if this is of any use, because I don't know the web
capabilities of your ipaq appliance, but there is a web page with an
online median calculator at
http://www.softintegration.com/chhtml/lang/lib/libch/numeric/CGI_Median.html
 You can set the matrix at any number of columns and rows it seems,
and the calculation gives you the median for the whole matrix and for
each column.  Of course, it will mean typing in all the numbers!
Subject: Re: finding the median
From: ulu-ga on 04 Jul 2002 10:11 PDT
 
A few more suggestion.

Scan the numbers to get a sense of the range and likely median.
Let say the numbers range from 1-100.
Pick some number that is obviously (from the scan) to be too low.
Also pick one that is too high.  Let's say 30 and 70.
Now go through the list crossing them off in pairs, one too high and
one too low.  (You probably want to use two hands/pointers/pencils
into your list).
You can now try to reduce the range again.  Notice which hand is at
the bottom of the list and come up with a new number closer to the
median.  Keep the other hand pointing where it is.  For our example
say there are still numbers higher than 70 on the list.  The hand ran
out of numbers less than 30 so now pick 40 and continue the process
from the top with that hand again.
You'll eventually hone into the median.
You might want to "cross off" in different colors or columns, in case
you reduced the range too small and need to backtrack.

An alternative is to go into Kinko's with a floppy.  Type in all the
numbers and compute the median and other stats and pretty graphs
(since they are all in the computer).

Another possibility is to ask youself, do I really need the median?
Sometimes that's the fastest way.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy