Concept and definition of mean
In statistics, we define as mean a single numeric value that describes synthetically a set of data.
There’re three types of mean: arithmetical, harmonic and geometrical mean. In statistics, we usually consider as mean the arithmetic mean. If the mean is computed by using the whole population it is called population mean, but if the values used are just a subset of the population the result is called sample mean. The equation to compute the arithmetic mean is the following:
A := 1/n sum(from i = 1 to n) of ai
This kind of approach is called ex post computation because to do that we need to collect the whole sample data before the computation. This isn’t always possible to do, so in some cases, we must use the expected mean or expected value, which is a measure of a central tendency where all data are weighted by their probability of occurring and then summed. The expected mean is an ex ante calculation (sometimes referred to as weighted mean where probabilities are the weights).
The mean can be used to extract some results and interpretations from data. For example, if we can calculate the distance between a value v of the population and the average m we can see that this value if it must be balanced by another set of value v’ who got the same distance from m. In formula:
distance(m,v) = sum[from i = 1 to d ](distance(m,v’)
Statistical mean is popular because it includes every item in the data set and it can easily be used with other statistical measurements. However, the major disadvantage in using statistical mean is that it can be affected by extreme values in the data set and therefore be biased. For example, mean income is typically skewed upwards by a small number of people with very large incomes, so that the majority have an income lower than the mean. To avoid these problems one of the solutions could be the Knuth algorithm:
# this is a Python implementation of Knuth alogorithm
n = 0
mean = 0
for x in data:
n = n + 1
delta = x - mean
mean = mean + delta/n
This algorithm is less subject to information loss given by floating point cancellation and rounded, but it could be less efficient than the naive implementation because of the division inside the loop.
The relationship between frequency and mean
To describe the focal point of a distribution, statisticians use a typical value from the distribution. The typical value and the most used is the arithmetic mean, usually simply called the mean. All you do is add up all of the members of the population and divide by how many members there are, N. Now you can notice that if there is more than one member of the population with a certain value, to add that value once for every member that has it. To reflect this, the equation for the mean sometimes is written: If instead of that we use the frequency of members of the population the result is equal.
The Markov inequality
We define X as a random positive variable, then we say that for every a > 0, we have
P(X>=a) <= E[X] / a
where E[X] is the mean of the random variable.
The Markov inequality allows us to limit the probability of rare events of random variables with a known mean. Because is an increase, the Markov inequality is useful when the distribution is not completely known. When the distribution is known this probability can be calculated exactly so it isn’t necessary to use any increase.