Learn
Mean
Calculating Mean

The mean, often referred to as the average, is a way to measure the center of a dataset.

The average of a set is calculated using a two-step process:

2. Divide the total sum from step one by the number of points in your dataset.
$\bar{x} = \frac{x_1 + x_2 … + x_{n}}{n}$

The equation above is used to calculate mean. x1, x2, … xn are observations from a dataset of n observations.

Example

Imagine that we wanted to calculate average of a dataset with the following four observations:

.gamut-clns7e-ColorizedContainer-fontSmoothing{display:block;text-align:left;font-weight:normal;background-color:#211E2F;color:#939598;font-family:Monaco,Menlo,"Ubuntu Mono","Droid Sans Mono",Consolas,monospace;font-size:0.875rem;padding:1rem;overflow-wrap:break-word;white-space:pre-wrap;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}data = [4, 6, 2, 8]
Step One: Calculate the total
$4 + 6 + 2 + 8 = 20$
Step Two: Divide by the number of observations

The total is equal to 20, and the number of observations is equal to 4.

$\frac{20}{4} = 5$

The average of this dataset is equal to 5.

Instructions

1.

In this exercise, you will use Python to find the average age of the first four authors in Le Monde’s top 100 books.

$29, 49, 42, 43$

Add the values together, and set total equal to the answer.

2.

Divide total by the number of values in the dataset, and set mean_value to the answer.

Take a look at the result in the terminal. Keep that number in your head as you progress through the lesson.