Tool to compute a mean from numbers. The arithmetic mean (or simply the mean/average) of a list of numbers is a statistical representation showing the distribution of the numbers in the list.

dCode is free and its tools are a valuable help in games, puzzles and problems to solve every day! You have a problem, an idea for a project, a specific need and dCode can not (yet) help you? You need custom development? Contact-me!

Tool to compute a mean from numbers. The arithmetic mean (or simply the mean/average) of a list of numbers is a statistical representation showing the distribution of the numbers in the list.

Answers to Questions

How to compute an arithmetic mean?

The arithmetic mean is the mathematical term to define what is simply called mean or average.

Consider a list of \( n \) values (digits, numbers, natural or real numbers) \( X = \{x_1, x_2, \dots, x_n \} \). The arithmetic mean is defined by the sum of the values divided by the number of values \( n \).

$$ \bar{x} = {1 \over n} \ sum_{i=1}^n{x_i} $$

The arithmetic mean is generally used to give a general trend to a set of homogeneous data, possibly bounded, for example school marks between 0 and 20.

Example: The list of \( 4 \) numbers \( \{ 12, 14, 18, 13 \} \) its average value is \( (12+14+18+13)/4 = 14.25 \)

This definition can be extended to a function, see function mean calculator.

To find the central value of a list, see median calculator.

When the values are assigned coefficients, see the weighted mean calculator.

How to code an arithmetic mean (source code)?

Classic method : // pseudocode function mean(array[N]) { sum = 0 for i = 0; i < N ; i++ { sum += array[i] } return sum / N }

Optimized method for floats (avoid big values) : // pseudocode function mean(array[N]) { m = 0 for i = 0; i < N; i++) { m += (array[i] - m)/(i+1); } return m }

Ask a new question

Source code

dCode retains ownership of the source code of the script Arithmetic Mean online. Except explicit open source licence (indicated Creative Commons / free), any algorithm, applet, snippet, software (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or any function (convert, solve, decrypt, encrypt, decipher, cipher, decode, code, translate) written in any informatic langauge (PHP, Java, C#, Python, Javascript, etc.) which dCode owns rights can be transferred after sales quote. So if you need to download the online Arithmetic Mean script for offline use, for you, your company or association, see you on contact page !

dCode uses cookies to customize the site content, analyze user behavior and adapt dCode to your use. Some data is stored and collected for advertising purposes and may be shared with our partners. OK