From Test-Scratch-Wiki

Revision as of 17:35, 19 March 2018 by HY2009 (talk | contribs) (Created page with "thumb|137px|The median of a set of five numbers. This tutorial will explain how to find the median of numbers. The median of a set of numbers is the middle...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The median of a set of five numbers.

This tutorial will explain how to find the median of numbers. The median of a set of numbers is the middle value. If the set of numbers has an even amount, the median is the average of the two middle numbers. For more information, see Wikipedia.

Sorting the Values

Main article: Sorting Values

The first step in finding the median is to sort the data from least to greatest. Doing this first will make this finding the median much easier.

Finding the Median

First, sort the values in order.

Once the values have been sorted, use the following script to get the median. Remember that the list "Data" contains the set of values. The variables "Med1" and "Med2" represent the values that will be used to solve for the median.

set [Med1 v] to (item ((length of [data v]) / (2)) of [data v])
set [Med2 v] to (item (((length of [data v]) / (2)) + (1)) of [data v])
if < ((length of [data v]) mod (2)) = (0)> then
say (join [median=] (((Med1) + (Med2)) / (2))) for (2) secs
else
say (join [median=] (item (((length of [data v]) / (2)) + (0.5)) of [data v])) for (2) secs
end

See Also