The "center" of a data set is also a way of describing location. The two most widely used measures of the "center" of the data are the mean (average) and the median. To calculate the mean weight of 50 people, add the 50 weights together and divide by 50. To find the median weight of the 50 people, order the data and find the number that splits the data into two equal parts (previously discussed under box plots in this chapter). The median is generally a better measure of the center when there are extreme values or outliers because it is not affected by the precise numerical values of the outliers. The mean is the most common measure of the center.
Note:
The mean can also be calculated by multiplying each distinct value by its frequency and then dividing the sum by the total number of data values. The letter used to represent the sample mean is an
The Greek letter
To see that both ways of calculating the mean are the same, consider the sample:
1, 1, 1, 2, 2, 3, 4, 4, 4, 4, 4
In the second example, the frequencies are 3, 2, 1, and 5.
You can quickly find the location of the median by using the expression
The letter
Example 1
Problem 1
AIDS data indicating the number of months an AIDS patient lives after taking a new antibody drug are as follows (smallest to largest):
3, 4, 8, 8, 10, 11, 12, 13, 14, 15, 15, 16, 16, 17, 17, 18, 21, 22, 22, 24, 24, 25, 26, 26, 27, 27, 29, 29, 31, 32, 33, 33, 34, 34, 35, 37, 40, 44, 44, 47
Calculate the mean and the median.
Solution
The calculation for the mean is:
To find the median, M, first use the formula for the location. The location is:
Starting at the smallest value, the median is located between the 20th and 21st values (the two 24s):
3; 4; 8; 8; 10; 11; 12; 13; 14; 15; 15; 16; 16; 17; 17; 18; 21; 22; 22;
The median is 24.
Calculating Mean and Median in R
As you might expect, R has in-built functions for calculating mean (mean()) and median (median()). Additionally it provides a summary() function that provides some basic descriptive statistics of the data.
# Enter the AIDS data
aids = c(3, 4, 8, 8, 10, 11, 12, 13, 14, 15, 15, 16,
16, 17, 17, 18, 21, 22, 22, 24, 24, 25, 26, 26,
27, 27, 29, 29, 31, 32, 33, 33, 34, 34, 35, 37,
40, 44, 44, 47)
# mean and median
mean(aids)
## [1] 23.57
median(aids)
## [1] 24
# summary statistics
summary(aids)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.0 15.0 24.0 23.6 32.2 47.0
Example 2
Problem 1
Suppose that, in a small town of 50 people, one person earns $5,000,000 per year and the other 49 each earn $30,000. Which is the better measure of the "center," the mean or the median?
Solution
(There are 49 people who earn $30,000 and one person who earns $5,000,000.)
The median is a better measure of the "center" than the mean because 49 of the values are 30,000 and one is 5,000,000. The 5,000,000 is an outlier. The 30,000 gives us a better sense of the middle of the data.




