Lecture #7: Measures of Center and of Position

STAT 200 – Introductory Statistics

Torin Quinlivan

Knox College

January 13, 2026

Today’s Objective

After today’s lecture, you should:

  • understand the importance of the formula for the mean:

    • know why we prefer to use the mean when we can
    • know when we should not use the mean to summarize the data
  • know how to calculate the mean, median, and mode;

  • know how to calculate the percentiles (quantiles):

    • quartiles, quintiles, deciles, etc.
  • calculate the \(z\)-score (a.k.a. the \(z\)-transformation);

  • calculate the correlation between two variables; and

  • perform the calculations in R.

Measures of Center

A measure of center of data is a number that represents the “typical” value in the data.

Examples:

  • mean
  • median
  • mode
  • weighted mean
  • mid-range

Sample Mean

The sample mean is the center of gravity of the data.

It is the most commonly used measure of center, whether it should be used or not.

The Central Limit Theorem (we’ll get to it soon, I promise) does explain why the mean gives us important information, whether it is the optimal measure of center or not.

This is the value you think of when you think of the word “average”.

Sample Mean

We denote the sample mean was \(\overline{x}\) (we say “x-bar”).

We denote the true population mean \(\mu\) (called “mu”, it’s a Greek lowercase m)

We tend to use Latin letters (\(Aa,Bb,Cc,Dd,\dots)\) for sample statistics, and Greek letters (\(A\alpha,B\beta,\Gamma\gamma,\Delta\delta,\dots)\) for population parameters.

Sample Mean

The formula is: \[ \overline{x} = \frac{1}{n} \sum_{i=1}^n x_i. \]

Written out, this formula is:

\[ \overline{x} = \frac{1}{n} \Big( x_1 + x_2 + \dots + x_{n-1} + x_n \Big) . \]

In English, this just means: Add all your data values together and divide by how many there are.

Sample Mean

Some notes on the sample mean:

  • Every data value is included in the calculation.
  • Every data value counts the same in the calculation.
  • The order does not matter in the calculation.

One thing to think about is how each data value affects the measure of center. If a single data value can change the measure to an infinitely large value, then the measure is not robust to outliers.

The mean is not robust. A single outlier can make the mean incredibly large (or small). The next example illustrates this.

Sample Mean Example

Suppose I went to Innkeeper’s Coffee and asked the customers there what they make in a year, to see what the mean salary of Innkeeper’s Coffee customers is. Here are the salaries (in thousands of dollars):

\[ 32.3,\, 56.1,\, 29.6,\, 78.9,\, 64.3,\, 57.0,\, 29.1 \]

Sample Mean Example

By hand:

\[ \begin{aligned} \overline{x} &= \frac{32.3 + 56.1 + 29.6 + 78.9 + 64.3 + 57.0 + 29.1}{7} \\ &= \frac{347.3}{7} \\ &= 49.614 \end{aligned} \]

In R:

salaries <- c(32.3, 56.1, 29.6, 78.9, 64.3, 57.0, 29.1)
mean(salaries)

Sample Mean Example

Now suppose Elon Musk walks into the coffeeshop. We add his $20,690,240,000 yearly income to the sample:

\[ 32.3,\, 56.1,\, 29.6,\, 78.9,\, 64.3,\, 57.0,\, 29.1,\, 20690240.0 \]

Sample Mean Example

By hand:

\[ \begin{aligned} \overline{x} &= \frac{32.3 + 56.1 + 29.6 + 78.9 + 64.3 + 57.0 + 29.1 + 20690240.0}{8} \\ &= \frac{20690587}{8} \\ &= 2586323 \end{aligned} \]

In R:

salaries2 <- c(32.3, 56.1, 29.6, 78.9, 64.3, 57.0, 29.1, 20690240.0)
mean(salaries2)

Sample Mean Example

Thus, with the inclusion of that single outlier, the mean increased by a factor of \(10^5\).

Because of this, we can see that the mean is definitely not robust to outliers.

Is this a good thing or a bad thing, in your opinion?

Weighted Mean

The weighted mean of the sample is similar to the regular mean, but each value in the sample gets a weight.

For instance, we might count the first value in the data set four times compared with the other only counting once.

As an example, in baseball, the batting average is the number of hits over the number of at-bats. In this calculation, a hit is equal to any other hit, a single is the same as a home run.

On the other hand, the slugging percentage is the total bases divided by the number of at-bats. In this calculation, a home run counts four times as much as a single.

Sample Median

The sample median is the “middle number” of a set of data, ranked from smallest to largest.

The key to the median is that about half of the data values are above it, and about half are below it.

When would this information be useful?

Sample Median

While there is a “formula” to calculate the median, we will use the following algorithm:

  1. Rank the values from lowest to highest.
  2. If the sample size is odd, the median is the middle ranked value.
  3. If the sample size is even, the median is the mean of the two middle ranked values.

Sample Median

Some notes on the sample median:

  • Every data rank (not value) is included in the calculation.
  • Every data rank (not value) counts the same in the calculation.
  • The order does matter in the calculation (eventually).

What do these tell us about how the median compares to the mean?

Note: In contrast to the mean, the median is robust to outliers.

Sample Median Example

Let’s calculate the median salary of our Innkeeper’s Coffee customers. Here are the salaries (in thousands of dollars):

\[ 32.3,\, 56.1,\, 29.6,\, 78.9,\, 64.3,\, 57.0,\, 29.1 \]

Sample Median Example

By hand:

First, we put the sample in order:

\[ 29.1,\, 29.6,\, 32.3,\, 56.1,\, 57.0,\, 64.3,\, 78.9 \]

Since \(n = 7\) is odd, the value at position \(\frac{n+1}{2} = 4\) the median is:

\[ \widetilde{x} = 56.1 \]

In R:

salaries <- c(32.3, 56.1, 29.6, 78.9, 64.3, 57.0, 29.1)
median(salaries)

Sample Median Example

Now let’s include Elon in our sample.

\[ 32.3,\, 56.1,\, 29.6,\, 78.9,\, 64.3,\, 57.0,\, 29.1,\, 20690240.0 \]

Sample Median Example

By hand:

First, we put the sample in order:

\[ 29.1,\, 29.6,\, 32.3,\, 56.1,\, 57.0,\, 64.3,\, 78.9,\, 20690240.0 \]

Now, because \(n = 8\) is even, the sample median is the mean of the middle two digits:

\[ \widetilde{x} = \frac{56.1 + 57.0}{2} = 56.55 \]

In R:

salaries2 <- c(32.3, 56.1, 29.6, 78.9, 64.3, 57.0, 29.1, 20690240.0)
median(salaries2)

Sample Median Example

Thus, with the inclusion of that single outlier, the median only increased by \(0.45\).

Because of this, we can see that the median is definitely robust to outliers.

Is this a good thing or a bad thing, in your opinion?

Sample Mode

The sample mode is the most prevalent value in a set of data.

When would this information be useful?

To calculate the mode by hand, determine which value occurs most often.

With this definition, do you think that the mode is robust to outliers? Please explain.

Sample Mode

Some notes on the sample mode:

  • Every data frequency is included in the “calculation”.
  • Every data value counts the same in determining the frequency.
  • The order does not matter in the calculation.
  • Comparing data values (other than exclusion) is not needed.

What do these tell us about how the mode compares to the mean and median?

Modality

Here is some terminology regarding the mode:

  • If one value occurs most frequently, then the data are unimodal.
  • If two values occurs most frequently, then the data are bimodal.
  • If more than two values occurs most frequently, then the data are multimodal.
  • If all values occur equally often, then the data have no mode.

Sample Mode Example

Let’s calculate the modal salary of our Innkeeper’s Coffee customers. Here are the salaries (in thousands of dollars):

\[ 32.3,\, 56.1,\, 29.6,\, 78.9,\, 64.3,\, 57.0,\, 29.1 \]

Sample Mode Example

By hand:

There is no mode, because all values happen once each.

In R:

# Install Dr. Forsberg's package
install.packages("devtools")
devtools::install_github("ojforsberg/KnoxStats")

# Load library "KnoxStats"
library(KnoxStats)

salaries <- c(32.3, 56.1, 29.6, 78.9, 64.3, 57.0, 29.1)
modal(salaries)

All of the Code

So, in summary, the above calculation can be done with this code:

library(KnoxStats)

salaries <- c(32.3, 56.1, 29.6, 78.9, 64.3, 57.0, 29.1)
salaries2 <- c(32.3, 56.1, 29.6, 78.9, 64.3, 57.0, 29.1, 20690240.0)

mean(salaries) 
median(salaries) 
modal(salaries)

mean(salaries2) 
median(salaries2) 
modal(salaries2)

Note that you need to be able to determine what each line of code does. Doing so will help you be able to think through someone else’s analysis and to better craft your own.

Measures of Position

If we care about describing the center of a variable, we would use a “measure of center”.

However, if we care about some other position in the variable, we would use a measure of position.

Measures of Position

Note that the measures of center are a specific type of measure of position.

Also note that most of these are related to the median instead of the mean.

  • Percentiles
  • Quartiles
  • Quintiles
  • Deciles
  • \(z\)-score (\(z\)-transformation)

Quantiles (a.k.a. Percentiles)

The \(k^{th}\) quantile (or percentile) is the value that seperates the lower \(k\%\) of the data from the upper \((100 - k)\%\) of the data.

Quantiles are useful when we want to discuss things that are not the middle. For instance:

  • In inequality research, we tend to focus on the \(10^{th}\) percentile to understand poverty.
  • In basic statistics, we tend to focus on the \(2.5^{th}\) and \(97.5^{th}\) percentiles to better understand uncertainty in our estimates.
  • Education research tends to focus on the \(5^{th}\), \(10^{th}\), or \(90^{th}\) percentile.

It all depends on your field of study. Ask around in your home department to see which percentile(s) you should focus on.

Quartiles

The median seperates the data into two equal parts. There may be times when we wish the divide the ordered data into four partsinto “quarters”.

Quartiles

The values that divide the ordered data into four parts are called the quartiles.

  • The first quartile, \(Q_1\): A value that separates the bottom 25% of the data from the top 75%.
  • The second quartile, \(Q_2\): A value that separates the bottom 50% of the data from the top 50%.
  • The third quartile, \(Q_3\): A value that separates the bottom 75% of the data from the top 25%.

Note that the second quartile is just the median; the value that separates the bottom 50% from the rest.

Other -iles

All of the -iles can be calculated in terms of the percentiles.

  • The median is the \(50^{th}\) percentile.
  • The values of \(Q_1\) and \(Q_3\) are the \(25^{th}\) and \(75^{th}\) percentiles.
  • The quintiles are the \(0^{th}\), \(20^{th}\), \(40^{th}\), \(60^{th}\), \(80^{th}\), and \(100^{th}\) percentiles.
  • The deciles are the \(0^{th}\), \(10^{th}\), \(20^{th}\), \(\dots\) \(100^{th}\) percentiles.

Other -iles

The R function to calculate the percentiles is quantile function.

The following code calculates the \(5^{th}\) and \(95^{th}\) percentiles of the salaries data loaded earlier:

quantile(salaries, c(0.05,0.95))

Note that the first slot is the variable name and the second is the percentile(s) that needs to be calculated.

Examples

For the original salaries data, calculate the following items:

  • mean
  • first quartile, \(Q_1\)
  • the \(90^{th}\) percentile
  • all quintiles
  • the difference between \(Q_1\) and \(Q_3\)

Examples

Code:

salaries <- c(32.3, 56.1, 29.6, 78.9, 64.3, 57.0, 29.1)

mean(salaries) 
quantile(salaries, 0.25)
quantile(salaries, 0.90)
quantile(salaries, c(0.0, 0.2, 0.4, 0.6, 0.8, 1.0))
quantile(salaries, 0.75) - quantile(salaries, 0.25)

Examples

For the updated salaries2 data, calculate the following items:

  • mean
  • first quartile, \(Q_1\)
  • the \(90^{th}\) percentile
  • all quintiles
  • the difference between \(Q_1\) and \(Q_3\)

Examples

Code:

salaries2 <- c(32.3, 56.1, 29.6, 78.9, 64.3, 57.0, 29.1, 20690240.0)

mean(salaries2) 
quantile(salaries2, 0.25)
quantile(salaries2, 0.90)
quantile(salaries2, c(0.0, 0.2, 0.4, 0.6, 0.8, 1.0))
quantile(salaries2, 0.75) - quantile(salaries2, 0.25)

The \(z\)-Transform

Finally, let us look at a transformation that allows us to compare entities across data sets —- the \(z\)-transform.

The \(z\)-transform is a function (transformation) applied to the data such that the transformed values have mean 0 and standard deviation 1.

The formula is rather straight-forward:

\[ z = \frac{x-\overline{x}}{s} \]

Why would we want to do something like this?

\(z\)-Score Example

In my MATH 145 course, I give two midterm exams. On the first, you scored 86; on the second, you scored 88.

  • Did you do better on the second exam?
  • Relative to others, did you do better on the second exam?

Answers:

  • Yes, by 2 points.
  • I do not know. There is not enough information.

\(z\)-Score Example

In my MATH 145 course, I give two midterm exams. On the first, you scored 86; on the second, you scored 88. The class averaged \(74 \pm 4\) on the first and \(78 \pm 10\) on the second.

  • Did you do better on the second exam?
  • Relative to others, did you do better on the second exam?

\(z\)-Score Example

Answers:

  • Still yes, still by 2 points.
  • To answer this question, we need to calculate the \(z\)-scores for your two tests:

\[ z_1 = \frac{x - \overline{x}_1}{s_1} = \frac{86 - 74}{4} = 3.00 \]

\[ z_2 = \frac{x - \overline{x}_2}{s_2} = \frac{88 - 78}{10} = 1.00 \]

\(z\)-Score Example

Your \(z\)-score on the first test was \(3.00\). Your \(z\)-score on the second test was \(1.00\). So, taking into consideration how well the other class members did, you did worse compared to them on the second test.

The interpretation of the \(z\)-score is straight-forward. On the first test, you scored three standard deviations above average. On the second, you only scored one standard deviation above average.

Note that the \(z\)-score can help you compare yourself to the class across tests. It controls for the difficulty of the examination. Since the interpretation deals with how far above (or below) the mean is in terms of standard deviations, the \(z\)-score can be used regardless of the units used for the original data.

Another Example

Goal: Determine how well Oregon did, in terms of the unemployment rate between 1990 and 2000, relative the the other states in the United States.

The usual analysis steps:

  1. Decide the analysis steps.
  2. Load the data.
  3. Calculate the statistics (perform the analysis).
  4. Interpret the results.

Another Example

This is the R code used for this analysis (along with a secondary analysis):

### Preamble
# More functionality 
library(KnoxStats)

# The data
dt = read.csv("http://rfs.kvasaheim.com/data/crime.csv") 
attach(dt)

### Analysis
# Absolute unemployment rates 
unemp1990[state=="Oregon"] 
unemp2000[state=="Oregon"]

# Relative unemployment rates 
zscore(unemp1990)[state=="Oregon"] 
zscore(unemp2000)[state=="Oregon"]    

Another Example

The output from the previous code tells us:

In 1990 and 2000, Oregon’s unemployment rates were \(5.6\%\) and \(4.9\%\), respectively. The corresponding \(z\)-scores are \(0.1138\) and \(0.9837\).

Interpretation:

While the unemployment rate in Oregon dropped from \(5.6\%\) to \(4.9\%\) between 1990 and 2000, relative to the other states in the United States, it actually increased by \(0.8699\) standard deviations. Thus, Oregon did worse than average in the 1990s in terms of the unemployment rate (the rate increased, relative to the typical state).