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:

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.

Month | Minimum temperature [°C] |

January | -7 |

February | -5 |

March | 2 |

April | 4 |

May | 7 |

June | 12 |

July | 19 |

August | 15 |

September | 11 |

October | 8 |

November | 4 |

December | -3 |

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

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); end 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 = 5.5833333 -->

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

#include<stdio.h> #include<math.h> 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!