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
| Name | Type | Description |
|---|---|---|
| data | iterable of numbers | Observations used by the statistic. |
| xbar | number or None | Known 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]))