ID EN
Statistics

NormalDist

Python 3.11

Returns a new NormalDist object where mu represents the arithmetic mean and sigma represents the standard deviation.

Syntax

PYTHON
class statistics.NormalDist(mu=0.0, sigma=1.0)

Examples

Example 1
PYTHON
>>> temperature_february = NormalDist(5, 2.5)              Celsius
>>> temperature_february * (9/5) + 32                      Fahrenheit
NormalDist(mu=41.0, sigma=4.5)
Example 2
PYTHON
>>> birth_weights = NormalDist.from_samples([2.5, 3.1, 2.1, 2.4, 2.7, 3.5])
>>> drug_effects = NormalDist(0.4, 0.15)
>>> combined = birth_weights + drug_effects
>>> round(combined.mean, 1)
3.1
>>> round(combined.stdev, 1)
0.5

See Also

StatisticsError fmean() stdev() iterable float StatisticsError list float