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)
| 607 | |
| 608 | |
| 609 | def 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 | |
| 632 | def pstdev(data, mu=None): |
no test coverage detected
searching dependent graphs…