# Connexions

You are here: Home » Content » Collaborative Statistics Using R » Measuring the Center of the Data

### Recently Viewed

This feature requires Javascript to be enabled.

Inside Collection (Textbook):

Textbook by: Ananda Mahto. E-mail the author

# Measuring the Center of the Data

Module by: Ananda Mahto. E-mail the author

Summary: This chapter discusses measuring descriptive statistical information using the center of the data

## Mean and Median

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 words "mean" and "average" are often used interchangeably. The substitution of one word for the other is common practice. The technical term is "arithmetic mean" and "average" is technically a center location. However, in practice among non-statisticians, "average" is commonly accepted for "arithmetic mean."

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 xx with a bar over it (pronounced "xx bar"): x¯ x .

The Greek letter μμ (pronounced "mew") represents the population mean. One of the requirements for the sample mean to be a good estimate of the population mean is for the sample taken to be truly random.

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

x ¯ = 1 + 1 + 1 + 2 + 2 + 3 + 4 + 4 + 4 + 4 + 4 11 = 2.7 x ¯ = 1 + 1 + 1 + 2 + 2 + 3 + 4 + 4 + 4 + 4 + 4 11 =2.7
(1)
x ¯ = 3 × 1 + 2 × 2 + 1 × 3 + 5 × 4 11 = 2.7 x ¯ = 3 × 1 + 2 × 2 + 1 × 3 + 5 × 4 11 =2.7
(2)

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 n + 1 2 n + 1 2 .

The letter nn is the total number of data values in the sample. If nn is an odd number, the median is the middle value of the ordered data (ordered smallest to largest). If nn is an even number, the median is equal to the two middle values added together and divided by 2 after the data has been ordered. For example, if the total number of data values is 97, then n + 1 2 n + 1 2 = 97 + 1 2 97 + 1 2 = 4949. The median is the 49th value in the ordered data. If the total number of data values is 100, then n + 1 2 n + 1 2 = 100 + 1 2 100 + 1 2 = 50.550.5. The median occurs midway between the 50th and 51st values. The location of the median and the value of the median are not the same. The upper case letter MM is often used to represent the median. The next example illustrates the location of the median and the value of the median.

### 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:

x ¯ = [ 3 + 4 + ( 8 ) ( 2 ) + 10 + 11 + 12 + 13 + 14 + ( 15 ) ( 2 ) + ( 16 ) ( 2 ) + ... + 35 + 37 + 40 + ( 44 ) ( 2 ) + 47 ] 40 = 23.6 x ¯ = [ 3 + 4 + ( 8 ) ( 2 ) + 10 + 11 + 12 + 13 + 14 + ( 15 ) ( 2 ) + ( 16 ) ( 2 ) + ... + 35 + 37 + 40 + ( 44 ) ( 2 ) + 47 ] 40 =23.6

To find the median, M, first use the formula for the location. The location is:

n + 1 2 = 40 + 1 2 = 20.5 n + 1 2 = 40 + 1 2 =20.5

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; 2424; 2424; 25; 26; 26; 27; 27; 29; 29; 31; 32; 33; 33; 34; 34; 35; 37; 40; 44; 44; 47

M = 24 + 24 2 = 24 M= 24 + 24 2 =24

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

x ¯ = 5000000 + 49 × 30000 50 = 129400 x ¯ = 5000000 + 49 × 30000 50 =129400

M = 30000 M=30000

(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.

## Mode

Another measure of the center is the mode. The mode is the most frequent value. If a data set has two values that occur the same number of times, then the set is bimodal.

### Example 3: Statistics exam scores for 20 students are as follows

Statistics exam scores for 20 students are as follows:

50, 53, 59, 59, 63, 63, 72, 72, 72, 72, 72, 76, 78, 81, 83, 84, 84, 84, 90, 93

#### Problem 1

Find the mode.

##### Solution

The most frequent score is 72, which occurs five times. Mode = 72.

### Calculating the Mode in R

R does not have an in-built function for calculating the mode, in part because a set of data is likely to have more than one mode. However, it is very easy to tabulate your data and see which value or values occur most frequently.



# Enter the exam scores data
exam.scores = c(50, 53, 59, 59, 63, 63, 72, 72, 72,
72, 72, 76, 78, 81, 83, 84, 84, 84, 90, 93)

# Use 'table' to find the mode
table(exam.scores)
## exam.scores
## 50 53 59 63 72 76 78 81 83 84 90 93
##  1  1  2  2  5  1  1  1  1  3  1  1

# That output is difficult to scan. Sort the
# output to make it easier to identify the most
# frequently occurring value.
sort(table(exam.scores))
## exam.scores
## 50 53 76 78 81 83 90 93 59 63 84 72
##  1  1  1  1  1  1  1  1  2  2  3  5
# 72 occurs 5 times, making it the mode.



### Example 4

Five real estate exam scores are 430, 430, 480, 480, 495. The data set is bimodal because the scores 430 and 480 each occur twice.

When is the mode the best measure of the "center"? Consider a weight loss program that advertises a mean weight loss of six pounds the first week of the program. The mode might indicate that most people lose two pounds the first week, making the program less appealing.

#### Note:

The mode can be calculated for qualitative data as well as for quantitative data.

Statistical software will easily calculate the mean, the median, and the mode. Some graphing calculators can also make these calculations. In the real world, people make these calculations using software.

## The Law of Large Numbers and the Mean

The Law of Large Numbers says that if you take samples of larger and larger size from any population, then the mean x ¯ x ¯ of the sample is very likely to get closer and closer to µµ. This is discussed in more detail in The Central Limit Theorem.

### Note:

The formula for the mean is located in the Summary of Formulas section course.

## Sampling Distributions and Statistic of a Sampling Distribution

You can think of a sampling distribution as a relative frequency distribution with a great many samples. (See Sampling and Data for a review of relative frequency). Suppose thirty randomly selected students were asked the number of movies they watched the previous week. The results are in the relative frequency table shown below.

Table 1
# of movies Relative Frequency
0 5/30
1 15/30
2 6/30
3 4/30
4 1/30

If you let the number of samples get very large (say, 300 million or more), the relative frequency table becomes a relative frequency distribution.

A statistic is a number calculated from a sample. Statistic examples include the mean, the median and the mode as well as others. The sample mean x ¯ x ¯ is an example of a statistic which estimates the population mean μμ.

## Glossary

Mean:
A number that measures the central tendency. A common name for mean is 'average.' The term 'mean' is a shortened form of 'arithmetic mean.' By definition, the mean for a sample (denoted by x¯ x ) is x¯ = Sum of all values in the sampleNumber of values in the sample x = Sum of all values in the sampleNumber of values in the sample size 12{ { bar {X}}= { {"Sum of all values in the sample"} over {"Number of values in the sample"} } } {}, and the mean for a population (denoted by μμ size 12{m} {}) is μ=Sum of all values in the populationNumber of values in the populationμ=Sum of all values in the populationNumber of values in the population size 12{m= { {"Sum of all values in the population"} over {"Number of values in the population"} } } {}.
Median:
A number that separates ordered data into halves. Half the values are the same number or smaller than the median and half the values are the same number or larger than the median. The median may or may not be part of the data.
Mode:
The value that appears most frequently in a set of data.

## Content actions

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

#### Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

#### Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks