0% found this document useful (0 votes)
3 views16 pages

Lecture Notes Descriptive Statistics

The document explains measures of central tendency (mean, median, mode), dispersion (range, variance, standard deviation), and position (percentiles, quartiles) in datasets. It details how to calculate each measure and when to use them based on data characteristics, emphasizing the importance of understanding data structure for analysis. Key takeaways include the sensitivity of the mean to outliers, the utility of the median in such cases, and the role of standard deviation in assessing data variation.

Uploaded by

mrfaad.playz
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views16 pages

Lecture Notes Descriptive Statistics

The document explains measures of central tendency (mean, median, mode), dispersion (range, variance, standard deviation), and position (percentiles, quartiles) in datasets. It details how to calculate each measure and when to use them based on data characteristics, emphasizing the importance of understanding data structure for analysis. Key takeaways include the sensitivity of the mean to outliers, the utility of the median in such cases, and the role of standard deviation in assessing data variation.

Uploaded by

mrfaad.playz
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Measures of central tendency: The mean, the median, and the mode

Recently, you learned that measures of central tendency are values that represent the center of a
dataset. When you’re working with a new dataset, identifying the central location of your data helps you
quickly understand its basic structure.

In this reading, you’ll learn more about three measures of central tendency: the mean, the median, and
the mode. We’ll go over how to calculate each measure, and discuss which measure is best to use based
on your specific data.

Measures of central tendency

The mean, median, and mode all describe the center of a dataset in different ways:

 The mean is the average value in a dataset.

 The median is the middle value in a dataset.

 The mode is the most frequently occurring value in a dataset.

Let’s explore how to calculate each measure of central tendency.

Calculate the mean, the median, and the mode

Mean

The mean is the average value in a dataset. To calculate the mean, you add up all the values in your
dataset and divide by the total number of values.

For example, say you have the following set of values: 10, 5, 3, 50, 12. To find the mean, you add all the
values for a total of 80. Then, you divide by 5, the total number of values.

(10+5+3+50+12)÷5=80÷5=16

The mean, or average value, is 16.


Median

The median is the middle value in a dataset. This means half the values in the dataset are larger than the
median, and half the values are smaller than the median.

You can find the median by arranging all the values in a dataset from smallest to largest. If you arrange
your five values in this way you get: 3, 5, 10, 12, 50. The median, or middle value, is 10.

If there are an even number of values in your dataset, the median is the average of the two middle
values. Let’s say you add another value, 8, to your set: 3, 5, 8, 10, 12, 50. Now, the two middle values are
8 and 10. To get the median, take their average.

(8+10)÷2=18÷2=9

The median is 9.

Mode

The mode is the most frequently-occurring value in a dataset. A dataset can have no mode, one mode,
or more than one mode.

For example, the set of numbers 1, 12, 33, 54, 75 has no mode because no value repeats. In the set 2, 7,
7, 11, 20 the mode is 7, because 7 is the only value that occurs more than once. The set 3, 12, 12, 40, 40
has two modes: 12 and 40.

When to use the mean, the median, and the mode

Whether you use the mean, median, or mode to describe the center of your dataset depends on the
specific data you’re working with and what insights you want to gain from your data. Let’s discuss some
general guidelines for using each measure of central tendency.

Mean versus median

Both the mean and the median describe the central location of a dataset. However, as measures of
central tendency, the mean and the median work better for different kinds of data.

The mean has one main disadvantage: it is very sensitive to outliers in your dataset. Recall that an
outlier is a value that differs greatly from the rest of the data.
If there are outliers in your dataset, the median is usually a better measure of the center. If there are no
outliers, the mean usually works well.

For example, imagine you want to compute the average annual salary for an employee at a small startup
company. You have the following salary data:

You can calculate the mean annual salary by adding up all the values in your dataset and dividing by the
total number of values. There are seven salaries in total, and their sum is $770,000.

$770,000÷7=$110,000

The mean salary for these seven employees is $110,000. However, the data suggests that this mean
value does not accurately reflect the typical salary of an employee at this company. Most employees
have a salary between $40,000–$50,000. In fact, only one employee has a salary greater than $50,000.
The salary of $500,000 is an outlier that pulls up the average, or skews the mean.

In this case, due to the presence of this outlier value, the median is a better measure of central
tendency than the mean. The median, or middle value, in this dataset is $45,000. The median gives you
a better idea of the typical salary for an employee at this company.

Mode

The mode is useful when working with categorical data because it clearly shows you which category
occurs most frequently. Say a company conducts an employee satisfaction survey. The main item on the
survey states, “I am satisfied with the opportunity I have to grow within the company.” Employees
choose among four categories for their response: strongly agree, agree, disagree, strongly disagree. A
bar chart summarizes the results.
The mode represents the highest bar in the bar chart, which refers to the rating “strongly agree.” This is
the most frequently-occurring rating in the dataset. The mode gives the company clear feedback on
employee satisfaction; in this case, positive feedback.

Key takeaways

Measures of central tendency such as the mean, median, and mode let you describe the center of your
dataset using a single value. As a data professional, knowing the center of your dataset helps you quickly
understand its basic structure and determine the next steps in your analysis.
Measures of dispersion: Range, variance, and standard deviation

Recently, you learned that measures of dispersion let you describe the spread of your dataset, or the
amount of variation in your data values. Measures of dispersion like standard deviation can give you an
initial understanding of the distribution of your data, and help you determine what statistical methods
to apply to your data.

In this reading, you’ll learn more about three measures of dispersion: the range, variance, and standard
deviation. This reading focuses on the foundational concept of standard deviation. As a data
professional, you’ll frequently calculate the standard deviation of your data, and use standard deviation
as part of more complex data analysis.

Measures of dispersion

Let’s examine out the definition of each measure of dispersion: the range, variance, and standard
deviation.

Range

The range is the difference between the largest and smallest value in a dataset.

For example, imagine you’re a biology teacher and you have data on scores for the final exam. The
highest score is 99/100, or 99%. The lowest score is 62/100, or 62%. To calculate the range, subtract the
lowest score from the highest score.

99 - 62 = 37

The range is 37 percentage points.

The range is a useful metric because it’s easy to calculate, and it gives you a very quick understanding of
the overall spread of your dataset.

Variance

Another measure of spread is called the variance, which is the average of the squared difference of each
data point from the mean. Basically, it’s the square of the standard deviation. You’ll learn more about
variance and how to use it in a later course.
Standard deviation

To get a better understanding of the concept of standard deviation, let’s explore its definition,
visualization, and statistical formula.

Definition

Standard deviation measures how spread out your values are from the mean of your dataset. It
calculates the typical distance of a data point from the mean. The larger the standard deviation, the
more spread out your values are from the mean. The smaller the standard deviation, the less spread out
your values are from the mean.

Visualization

Let’s examine the plots of three normal probability distributions to get a better idea of spread. Later on,
you’ll learn about distributions, which map all the values in a dataset. For now, just know that the mean
is the highest point on each curve, right in the center.

Each curve has the same mean and a different standard deviation. The standard deviation of the blue
dotted curve is 1, the green solid curve is 2, and the red dashed curve is 3. The blue dotted curve has the
least spread since most of its data values fall close to the mean. Therefore, the blue dotted curve has the
smallest standard deviation. The red dashed curve has the most spread since most of its data values fall
farther away from the mean. Therefore, the red dashed curve has the largest standard deviation.

Formula

Now let’s discuss how you calculate standard deviation using a formula.

There are different formulas to calculate the standard deviation for a population and a sample. As a
reminder, data professionals typically work with sample data, and they make inferences about
populations based on the sample. So, let’s review the formula for sample standard deviation:

In the formula, n is the total number of data values in your sample, x is each individual data value, and x̄
(pronounced “x-bar”) is the mean of your data values. The Greek letter Sigma is a symbol that means
sum.

Note: As a data professional, you’ll typically use a computer for calculations. Being able to perform
calculations is important for your future career, but being familiar with the concepts behind the
calculations will help you apply statistical methods to workplace problems.

To better understand the different parts of the formula, let’s calculate the sample standard deviation of
a small dataset: 2, 3, 10.

You can do this in five steps:

1. Calculate the mean, or average, of your data values.

(2 + 3 +10) ÷ 3 = 15 ÷ 3 = 5

2. Subtract the mean from each value.

2 - 5 = -3

3 - 5 = -2
10 - 5 = 5

3. Square each result.

-3 * -3 = 9

-2 * -2 = 4

5 * 5 = 25

4. Add up the squared results and divide this sum by one less than the number of data values. This is
the variance.

(9 + 4 + 25) ÷ (3 -1) = 38 ÷ 2 = 19

5. Finally, find the square root of the variance.

√19 = 4.36

The sample standard deviation is 4.36.

Now that you know more about the concept of standard deviation, let’s check out an example of its
practical application.

Example: Real estate prices

Imagine you're a data professional working for a real estate company. The real estate agents on your
team like to inform their clients about the variation in rental prices in different residential areas. Part of
your job is calculating the standard deviation of monthly rental prices for apartments in specific
neighborhoods, and sharing this information with your team. Let’s say you have sample data on monthly
rental prices for one-bedroom apartments in two different neighborhoods: Emerald Woods and Rock
Park. Assume you calculate the mean and standard deviation for each dataset.

Emerald Woods
Both neighborhoods have the same mean rental price of $1,000 per month. However, the standard
deviation for rental prices in Rock Park ($431.56) is much higher than the standard deviation for rental
prices in Emerald Woods ($79.05). This means that there is a lot more variation in rental prices in Rock
Park. This is useful information for your agents. For example, they can tell clients that it may be easier
for them to find a more affordable apartment in Rock Park that is far below the mean of $1,000.
Standard deviation helps you quickly understand the variation in prices in any given neighborhood.

Key takeaways

Data professionals use standard deviation to measure variation in many types of data like ad revenues,
stock prices, employee salaries, and more. Measures of dispersion like the standard deviation, variance,
and range let you quickly identify the variation in your data values, and get a better understanding of
the basic structure of your data.

Measures of position: Percentiles and quartiles

Recently, you learned that measures of position let you determine the position of a value in relation to
other values in a dataset. Along with center and spread, it’s helpful to know the relative position of your
values. For example, whether one value is higher or lower than another, or whether a value falls in the
lower, middle, or upper portion of your dataset.

In this reading, you’ll learn more about the most common measures of position: percentiles and
quartiles. You’ll also learn how to calculate the interquartile range, and use the five number summary to
summarize your data.

Measures of position

Percentile

A percentile is the value below which a percentage of data falls. Percentiles divide your data into 100
equal parts. Percentiles give the relative position or rank of a particular value in a dataset.

For example, percentiles are commonly used to rank test scores on school exams. Let’s say a test score
falls in the 99th percentile. This means the score is higher than 99% of all test scores. If a score falls in
the 75th percentile, the score is higher than 75% of all test scores. If a score falls in the 50th percentile,
the score is higher than half, or 50%, of all test scores.

Note: Percentiles and percentages are distinct concepts. For example, say you score 90/100, or 90%, on a
test. This doesn’t necessarily mean your score of 90% is in the 90th percentile. Percentile depends on the
relative performance of all test takers. If half of all test takers score above 90%, then a score of 90% will
be in the 50th percentile.

Percentiles are useful for comparing values and putting data in context. For example, imagine you want
to buy a new car. You’d like a midsize sedan with great fuel economy. In the United States fuel economy
is measured in miles per gallon of fuel, or mpg. The sedan you’re considering gets 23 mpg. Is that good
or bad? Without a basis for comparison, it’s hard to know. However, if you know that 23 mpg is in the
25th percentile of all midsize sedans, you have a much clearer idea of its relative performance. In this
case, 75% of all midsize sedans have a higher mpg than the car you’re thinking about buying.

Quartile

You can use quartiles to get a general understanding of the relative position of values. A quartile divides
the values in a dataset into four equal parts.

Three quartiles divide the data into four quarters. Quartiles let you compare values relative to the four
quarters of data. Each quarter includes 25% of the values in your dataset.

 The first quartile, Q1, is the middle value in the first half of the dataset. Q1 refers to the 25th percentile.
25% of the values in the entire dataset are below Q1, and 75% are above it.

 The second quartile, Q2, is the median of the dataset. Q2 refers to the 50th percentile. 50% of the
values in the entire dataset are below Q2, and 50% are above it.

 The third quartile, Q3, is the middle value in the second half of the dataset. Q3 refers to the 75th
percentile. 75% of the values in the entire dataset are below Q3, and 25% are above it.
Example: Car sales

For example, imagine you’re a data professional working for an auto dealership. The manager of the
sales team wants to compare the performance of each sales representative on the team. The manager
asks you to analyze data that provides how many cars each sales representative sold during the past
month.

You can calculate quartiles for your data in four steps:

1. Arrange the values in your dataset from smallest to largest.

[6, 7, 9, 10, 10, 13, 15, 18]

2. Find the median, or middle value, of your entire dataset. This is Q2. There are an even number of
values in the dataset, so the median is the average of the two middle values, 10 and 10.

Q2 = (10 + 10) ÷ 2 = 20 ÷ 2 = 10

3. Find the median of the lower half of your dataset [6, 7, 9, 10]. This is Q1. The median is the average
of the two middle values, 7 and 9.

Q1 = (7 + 9) ÷ 2 = 16 ÷ 2 = 8

4. Finally, find the median of the upper half of your dataset [10, 13, 15, 18]. This is Q3. The median is the
average of the two middle values, 13 and 15.

Q3 = (13 + 15) ÷ 2 = 28 ÷ 2 = 14

Dividing the data into quartiles gives you a clear idea of sales rep performance. You now know that the
lower quartile (Q1) of reps sold 8 cars or fewer, and the upper quartile (Q3) sold 14 cars or more. In
other words, the lower 25% of reps sold 8 cars or fewer, and the upper 25% sold 14 cars or more. The
middle 50% of representatives sold between 8 and 14 cars.

Note: This is not the only way to calculate quartile values. For datasets with many observations, the
quartile calculation methodology has a negligible effect on the final calculated values. However, for
datasets with few observations, the calculated quartiles may be not insignificant. Numpy’s percentile()
function, for example, has nine different ways to calculate a given percentile.

Interquartile range (IQR)

The middle 50% of your data is called the interquartile range, or IQR. The interquartile range is the
distance between the first quartile (Q1) and the third quartile (Q3). This is the same as the distance
between the 25th and 75th percentiles. IQR is useful for determining the relative position of your data
values. For instance, data values outside the interval Q1 - (1.5 * IQR) and Q3 + (1.5 * IQR) are often
considered outliers.

Note: Technically, IQR is a measure of dispersion because it measures the spread of the middle half or
middle 50% of your data (between Q1 and Q3). IQR is less sensitive to outliers than the range because it
doesn’t include the more extreme values in your dataset.

IQR = Q3 - Q1. In this case, Q3 = 14 and Q1 = 8.

IQR = 14 - 8 = 6

Five number summary

Finally, you can summarize the major divisions in your dataset with the five number summary. The five
numbers include:

 The minimum

 The first quartile (Q1)

 The median, or second quartile (Q2)

 The third quartile (Q3)

 The maximum

The five number summary is useful because it gives you an overall idea of the distribution of your data,
from the extreme values to the center. You can visualize it with a box plot.
The box part of the box plot goes from Q1 to Q3. The vertical line in the middle of the box is the median
(Q2). The horizontal lines on each side of the box, known as whiskers, go from Q1 to the minimum, and
from Q3 to the maximum.

The following box plot illustrates the data on car sales. You can find the values on the box plot and
determine the interquartile range (IQR). The IQR is the length of the box, or the distance from Q1 to Q3.

Key takeaways

Data professionals use measures of position such as percentiles and quartiles to better understand all
types of data, from product sales to household income. Measures of position help you quickly identify
the relative location of your data values, and give you a more precise sense of the distribution of your
data.
Practice Questions

Q1 Can you explain how measures of central tendency, such as the mean and median, differ from each
other in terms of their calculation and what they represent in a dataset?

Q2 Can you think of a scenario where using the median would be more appropriate than using the
mean? Why would that be the case?

Q3 Which Python library would you typically use to compute descriptive statistics, including the mean
and median, and what is one key function from that library that can help you with this?

Q4 What two Python functions can you use to compute the range of your dataset?

Q5 How does understanding the range of a dataset help in the context of data analysis? Can you provide
an example of its significance?

Q6 Can you explain what variance measures in a dataset and how it is calculated?

Q7 What is the relationship between variance and standard deviation, and why might one be preferred
over the other in data analysis?

Q8 Imagine you have two datasets: Dataset A has a variance of 4, and Dataset B has a variance of 16.
What can you infer about the spread of values in these datasets?

Q9 If you were to calculate the standard deviation for both datasets, what would the standard
deviations be, and how would that further inform your analysis?

You might also like