It is nice to find reference on the Internet but the one you gave (it is
also in Webster), as well as the notion of "calculating" a median, are
skewed simplifications of the real definition. In fact you cannot
"calculate" a median, you can simply "estimate" it.

The notion of central position has been replaced by a definition applicable
to all situations such as "Numerically, half of the scores in a population
will have values that are equal to or larger than the median and half will
have values that are equal to or smaller than the median." (also on the
internet and acceptable to statisticians).

If the number of cases in the list is odd, the best estimate is the central
value (it is not calculated, by definition it is it). If the number of cases
is even, any value between the two "central" values can do it; if one
decides to take the average of these values, it is an oversimplification.
And what about when values are integers? Would the median be a decimal
number? Because one must "add" and "divide", that gives the impression that
it is calculated and seems to attach to it a quality of mathematical
reliability that is completely absent from the original definition of this
"distribution indices" in statistics.

In a strict "statistician" point of view, one should adopt the solution I
offer in my MB_Stats.mbx : reporting two "central" values ("The median lies
between  and  ); if the number of cases is odd, they are both set to the
unique value; if they are even, they may be different (and the user should
know how to interpret them) or equal (repetition of the same value around
the "center")

Jacques Paris
e-mail  [EMAIL PROTECTED]
MapBasic-MapInfo support  http://www.paris-pc-gis.com

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
[EMAIL PROTECTED]
Sent: July 2, 2002 13:07
To: [EMAIL PROTECTED]
Subject: RE: MI-L calculating median?

In answer to a posting by Frank Hebbert on 6/24:

Here's something I wrote up for MapInfo's Knowledge Base last time the
question of calculating medians came up.  The information below really
ought to be a compiled into nice simple fifty-line MapBasic tool, but I've
been a bit short of time recently ... so I haven't put the document into
the public KB yet.

Issue:
How can the median of a column of data be calculated in MapInfo
Professional?

Discussion:
The median value is not one of the aggregate functions provided with
MIPro.

Here's an Internet definition of "median":
The median of an ordered list is the middle value if the number of
elements is odd.  If the number of elements is even, then the median is
the average of the two middle values.

The mean (average) depends on the distribution.  If the distribution is
either positively or negatively skewed, then the median will not equal the
mean.

---------------------------------------------------------

It's easy enough to calculate the median in a MapBasic program, or even in
a series of SQL-type statements:

Select (your column) from (your table) Order By (your column) into Temp
Look at the status bar for the resulting browser window.
If the number of records is even, do
        Select Avg({your column}) "Median" from Temp where RowID={number
of records}/2 or RowID={number of records}/2+1 Into MedianFinal
If the number of records is odd, do
        Select ({your column}) "Median" from Temp where RowID={number of
records+1)/2 Into MedianFinal


Conclusion:
You can write a single Select statement that would work whether or not the
number of records was even or odd, though it's kind of ugly...  e.g. you
could copy and paste the code below into the MapBasic window, and it would
give you the median value for the relevant column.

You just need to alter the second and third lines to match your table and
column names before you select the whole mess of code and hit [Enter]:

        dim MedianTable as string, ColName as string, n as integer
        MedianTable="SalesTable"
        ColName="SalesCol"
        Run Command "Select " & ColName & " from " & MedianTable & " Order
By " & ColName & " Into Temp NoSelect"
        n=TableInfo(Temp, 8)
        Run Command "Select Avg(" & ColName & ") ""Median"" from Temp
where RowID=int((n+1)/2) or RowID=int((n+2-(n mod 2))/2) into MedianFinal
NoSelect"
        Browse * from MedianFinal
        Undim MedianTable Undim ColName Undim n

But that's about the best you can do without putting all this into a
MapBasic tool.


Dave G.
MapInfo Technical Support


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to