Statistics Functions

statistics.variance()

Estimate population variance from a sample using squared deviations divided by n-1. Supply xbar only if it is the actual sample mean.

Formal Syntax & Structure

python syntaxpython
statistics.variance(data, xbar=None)

Parameters & Attributes

NameTypeDescription
dataiterable of numbersObservations used by the statistic.
xbarnumber or NoneKnown sample mean, or None to calculate it.

Return Value

number

Numeric result; concrete type depends on inputs.

Working Example

Example Snippetpython
import statisticsprint(statistics.variance([2, 4, 6]))
Python Reference