Unless explicitly noted otherwise, these functions support int,
float, decimal.Decimal and fractions.Fraction.
Behaviour with other types (whether in the numeric tower or not) is
currently unsupported. Mixed types are also undefined and
implementation-dependent. If your input data consists of mixed types,
you may be able to use map() to ensure a consistent result, e.g.
map(float,input_data).

Return the sample arithmetic mean of data which can be a sequence or iterator.

The arithmetic mean is the sum of the data divided by the number of data
points. It is commonly called “the average”, although it is only one of many
different mathematical averages. It is a measure of the central location of
the data.

The mean is strongly affected by outliers and is not a robust estimator
for central location: the mean is not necessarily a typical example of the
data points. For more robust, although less efficient, measures of
central location, see median() and mode(). (In this case,
“efficient” refers to statistical efficiency rather than computational
efficiency.)

The sample mean gives an unbiased estimate of the true population mean,
which means that, taken on average over all the possible samples,
mean(sample) converges on the true mean of the entire population. If
data represents the entire population rather than a sample, then
mean(data) is equivalent to calculating the true population mean μ.

Return the harmonic mean of data, a sequence or iterator of
real-valued numbers.

The harmonic mean, sometimes called the subcontrary mean, is the
reciprocal of the arithmetic mean() of the reciprocals of the
data. For example, the harmonic mean of three values a, b and c
will be equivalent to 3/(1/a+1/b+1/c).

The harmonic mean is a type of average, a measure of the central
location of the data. It is often appropriate when averaging quantities
which are rates or ratios, for example speeds. For example:

Suppose an investor purchases an equal value of shares in each of
three companies, with P/E (price/earning) ratios of 2.5, 3 and 10.
What is the average P/E ratio for the investor’s portfolio?

>>> harmonic_mean([2.5,3,10])# For an equal investment portfolio.3.6

Using the arithmetic mean would give an average of about 5.167, which
is too high.

StatisticsError is raised if data is empty, or any element
is less than zero.

Return the median of grouped continuous data, calculated as the 50th
percentile, using interpolation. If data is empty, StatisticsError
is raised. data can be a sequence or iterator.

>>> median_grouped([52,52,53,54])52.5

In the following example, the data are rounded, so that each value represents
the midpoint of data classes, e.g. 1 is the midpoint of the class 0.5–1.5, 2
is the midpoint of 1.5–2.5, 3 is the midpoint of 2.5–3.5, etc. With the data
given, the middle value falls somewhere in the class 3.5–4.5, and
interpolation is used to estimate it:

>>> median_grouped([1,2,2,3,4,4,4,4,4,5])3.7

Optional argument interval represents the class interval, and defaults
to 1. Changing the class interval naturally will change the interpolation:

Return the population variance of data, a non-empty iterable of real-valued
numbers. Variance, or second moment about the mean, is a measure of the
variability (spread or dispersion) of data. A large variance indicates that
the data is spread out; a small variance indicates it is clustered closely
around the mean.

If the optional second argument mu is given, it should be the mean of
data. If it is missing or None (the default), the mean is
automatically calculated.

Use this function to calculate the variance from the entire population. To
estimate the variance from a sample, the variance() function is usually
a better choice.

When called with the entire population, this gives the population variance
σ². When called on a sample instead, this is the biased sample variance
s², also known as variance with N degrees of freedom.

If you somehow know the true population mean μ, you may use this function
to calculate the variance of a sample, giving the known population mean as
the second argument. Provided the data points are representative
(e.g. independent and identically distributed), the result will be an
unbiased estimate of the population variance.

Return the sample variance of data, an iterable of at least two real-valued
numbers. Variance, or second moment about the mean, is a measure of the
variability (spread or dispersion) of data. A large variance indicates that
the data is spread out; a small variance indicates it is clustered closely
around the mean.

If the optional second argument xbar is given, it should be the mean of
data. If it is missing or None (the default), the mean is
automatically calculated.

Use this function when your data is a sample from a population. To calculate
the variance from the entire population, see pvariance().

This is the sample variance s² with Bessel’s correction, also known as
variance with N-1 degrees of freedom. Provided that the data points are
representative (e.g. independent and identically distributed), the result
should be an unbiased estimate of the true population variance.

If you somehow know the actual population mean μ you should pass it to the
pvariance() function as the mu parameter to get the variance of a
sample.