STAT 200 – Introductory Statistics
January 13, 2026
After today’s lecture, you should:
understand the importance of the formula for the mean:
know how to calculate the mean, median, and mode;
know how to calculate the percentiles (quantiles):
calculate the \(z\)-score (a.k.a. the \(z\)-transformation);
calculate the correlation between two variables; and
perform the calculations in R.
A measure of center of data is a number that represents the “typical” value in the data.
Examples:
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”.
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.
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.
Some notes on the sample mean:
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.
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 \]
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} \]
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 \]
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} \]
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?
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.
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?
While there is a “formula” to calculate the median, we will use the following algorithm:
Some notes on the sample median:
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.
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 \]
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 \]
Now let’s include Elon in our sample.
\[ 32.3,\, 56.1,\, 29.6,\, 78.9,\, 64.3,\, 57.0,\, 29.1,\, 20690240.0 \]
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 \]
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?
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.
Some notes on the sample mode:
What do these tell us about how the mode compares to the mean and median?
Here is some terminology regarding the mode:
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 \]
By hand:
There is no mode, because all values happen once each.
So, in summary, the above calculation can be done with this code:
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.
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.
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.
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:
It all depends on your field of study. Ask around in your home department to see which percentile(s) you should focus on.
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”.
The values that divide the ordered data into four parts are called the quartiles.
Note that the second quartile is just the median; the value that separates the bottom 50% from the rest.
All of the -iles can be calculated in terms of the percentiles.
The R function to calculate the percentiles is quantile function.
For the original salaries data, calculate the following items:
Code:
For the updated salaries2 data, calculate the following items:
Code:
Finally, let us look at a transformation that allows us to compare entities across data sets —- the
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?
In my MATH 145 course, I give two midterm exams. On the first, you scored 86; on the second, you scored 88.
Answers:
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.
Answers:
\[ 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 \]
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.
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:
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"] 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).