How to calculate the arithmetic mean

For a given (discrete) set of data, the arithmetic mean is the representation of a central value. A common name for the arithmetic mean value is the average.

The set of data used for arithmetic mean calculation is most of the time obtained by sampling or measurement from a statistical population.

In mathematics the arithmetic mean is typically denoted as an x with a bar above.


If we have an N number of sample data (measurements), each denoted as x1, x2, …, xN, the arithmetic mean is calculated by summing all the values together and dividing them to the total number of value:

\[\overline{x} = \frac{x_1+x_2+ … + x_N}{N}\]

The general mathematical expression for the arithmetic mean is:

\[\overline{x} = \frac{\sum_{i=1}^{N}x_i}{N}\]

Example: Calculate the arithmetic mean (average) of the monthly minimum temperature for the given set of data.

MonthMinimum temperature [°C]

We are given 12 measurements of the temperatures, the minimum value for each month. The minimum average temperature for the whole year is the arithmetic mean of the data set:

\[\overline{x} = \frac{-7-5+2+4+7+12+19+15+11+8+4-3}{12}=\frac{67}{12}=5.5833\]

For a better understanding of the result we are going to plot:

  • each monthly minimum temperature as a bar plot
  • the arithmetic mean (yearly minimum average temperature) as a line
Monthly minimum temperatures and yearly minimum average

Image: Monthly minimum temperatures and yearly minimum average

As a programming exercise, we’ll write a Scilab script which calculates the arithmetic mean for the same set of data:

data_N = [-7 -5 2 4 7 12 19 15 11 8 4 -3];
length_N = length(data_N);
sum_N = 0;

for i=1:length_N
 sum_N = sum_N + data_N(i); 

x_AM = sum_N / length_N;
mprintf("The arithmetic mean is: %f", x_AM);

There is also the built-in Scilab function mean() which calculates the arithmetic mean:

-->mean([-7 -5 2 4 7 12 19 15 11 8 4 -3])
 ans =

For further practicing we are going to write down a C script which calculates the arithmetic mean for the same set of data (temperatures):


int main(void)
 double data_N[12] = {-7,-5,2,4,7,12,19,15,11,8,4,-3};
 int i;
 double sum_N = 0;
 double x_AM = 0;
 double length_N = 12;

for (i=0;i<length_N;i++){
 sum_N = sum_N + data_N[i];

x_AM = sum_N/length_N;
 printf("The arithmetic mean is %f: \n",x_AM);

return 0;

For any questions or observations regarding this tutorial please use the comment form below.

Don’t forget to Like, Share and Subscribe!

Leave a Reply

Ad Blocker Detected

Dear user, Our website provides free and high quality content by displaying ads to our visitors. Please support us by disabling your Ad blocker for our site. Thank you!