MCPcopy Index your code
hub / github.com/python/cpython / stdev

Function stdev

Lib/statistics.py:609–629  ·  view source on GitHub ↗

Return the square root of the sample variance. See ``variance`` for arguments and other details. >>> stdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75]) 1.0810874155219827

(data, xbar=None)

Source from the content-addressed store, hash-verified

607
608
609def stdev(data, xbar=None):
610 """Return the square root of the sample variance.
611
612 See ``variance`` for arguments and other details.
613
614 >>> stdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75])
615 1.0810874155219827
616
617 """
618 T, ss, c, n = _ss(data, xbar)
619 if n < 2:
620 raise StatisticsError('stdev requires at least two data points')
621 mss = ss / (n - 1)
622 try:
623 mss_numerator = mss.numerator
624 mss_denominator = mss.denominator
625 except AttributeError:
626 raise ValueError('inf or nan encountered in data')
627 if issubclass(T, Decimal):
628 return _decimal_sqrt_of_frac(mss_numerator, mss_denominator)
629 return _float_sqrt_of_frac(mss_numerator, mss_denominator)
630
631
632def pstdev(data, mu=None):

Callers 1

_test_generatorFunction · 0.90

Calls 4

_ssFunction · 0.85
StatisticsErrorClass · 0.85
_decimal_sqrt_of_fracFunction · 0.85
_float_sqrt_of_fracFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…