In one pass, compute the mean and sample standard deviation as floats.
(data)
| 941 | |
| 942 | |
| 943 | def _mean_stdev(data): |
| 944 | """In one pass, compute the mean and sample standard deviation as floats.""" |
| 945 | T, ss, xbar, n = _ss(data) |
| 946 | if n < 2: |
| 947 | raise StatisticsError('stdev requires at least two data points') |
| 948 | mss = ss / (n - 1) |
| 949 | try: |
| 950 | return float(xbar), _float_sqrt_of_frac(mss.numerator, mss.denominator) |
| 951 | except AttributeError: |
| 952 | # Handle Nans and Infs gracefully |
| 953 | return float(xbar), float(xbar) / float(ss) |
| 954 | |
| 955 | |
| 956 | # === Statistics for relations between two inputs === |
no test coverage detected