File: //usr/lib64/python3.8/__pycache__/statistics.cpython-38.pyc
U
e5d
@ s d Z ddddddddd d
ddd
ddddgZddlZddlZddlZddlmZ ddlmZ ddl m
Z
ddlmZm
Z
ddlmZmZmZmZmZmZmZmZ ddlmZ ddlmZ G dd deZdeddZdd Zd d! Zd"d# Zd$d% Z d&d' Z!d(d) Z"dfd+d,Z#d-d Z$d.d Z%d/d Z&d0d Z'd1d Z(d2d
Z)d3d Z*dgd5dZ+d6d Z,d7d Z-d8d9d:d;dZ.dhd<d=Z/did>dZ0djd?dZ1dkd@dZ2dldAd
Z3dBdC Z4G dDd dZ5zddEl6m4Z4 W n e7k
r Y nX e8dFkrddGlm9Z9 ddHlm:Z:m;Z;m<Z<m=Z= ddIl m>Z> ddl?Z?e5dJdKZ@e5dLdMZAe@dN dN j$e@j$ksLtBe@dN dN j2e@j2ksftBdOZCe@DeCZEeADeCZFe:e;fD ]<ZGeHdPeGj8 dQ eHeGe@eA eHe5IeJeGeEeF qdRZKe:e;e<e=fD ]@ZGeHdPeGj8 dS eHeGe@eK eHe5IeJeGeEe>eK qdTZKe:e;e<fD ]@ZGeHdUeGj8 dV eHeGeKe@ eHe5IeJeGe>eKeE q$dWdX ZLe5dYdZZMe5d[d\ZNd]ZOdOZCe5Id^d_ eMDeCD ZPeLeMeO eP e5Id`d_ eMDeCD ZPeLeMeO eP e5Idad_ eMDeCD ZPeLeMeO eP e5Idbd_ eMDeCD ZPeLeMeO eP e5Idcd_ eQeMDeCeNDeCD ZPeLeMeN eP e5Iddd_ eQeMDeCeNDeCD ZPeLeMeN eP eHe?R dS )mam
Basic statistics module.
This module provides functions for calculating statistics of data, including
averages, variance, and standard deviation.
Calculating averages
--------------------
================== ==================================================
Function Description
================== ==================================================
mean Arithmetic mean (average) of data.
fmean Fast, floating point arithmetic mean.
geometric_mean Geometric mean of data.
harmonic_mean Harmonic mean of data.
median Median (middle value) of data.
median_low Low median of data.
median_high High median of data.
median_grouped Median, or 50th percentile, of grouped data.
mode Mode (most common value) of data.
multimode List of modes (most common values of data).
quantiles Divide data into intervals with equal probability.
================== ==================================================
Calculate the arithmetic mean ("the average") of data:
>>> mean([-1.0, 2.5, 3.25, 5.75])
2.625
Calculate the standard median of discrete data:
>>> median([2, 3, 4, 5])
3.5
Calculate the median, or 50th percentile, of data grouped into class intervals
centred on the data values provided. E.g. if your data points are rounded to
the nearest whole number:
>>> median_grouped([2, 2, 3, 3, 3, 4]) #doctest: +ELLIPSIS
2.8333333333...
This should be interpreted in this way: you have two data points in the class
interval 1.5-2.5, three data points in the class interval 2.5-3.5, and one in
the class interval 3.5-4.5. The median of these data points is 2.8333...
Calculating variability or spread
---------------------------------
================== =============================================
Function Description
================== =============================================
pvariance Population variance of data.
variance Sample variance of data.
pstdev Population standard deviation of data.
stdev Sample standard deviation of data.
================== =============================================
Calculate the standard deviation of sample data:
>>> stdev([2.5, 3.25, 5.5, 11.25, 11.75]) #doctest: +ELLIPSIS
4.38961843444...
If you have previously calculated the mean, you can pass it as the optional
second argument to the four "spread" functions to avoid recalculating it:
>>> data = [1, 2, 2, 4, 4, 4, 5, 6]
>>> mu = mean(data)
>>> pvariance(data, mu)
2.5
Exceptions
----------
A single exception is defined: StatisticsError is a subclass of ValueError.
NormalDistStatisticsErrorfmeangeometric_mean
harmonic_meanmeanmedianmedian_groupedmedian_high
median_lowmode multimodepstdev pvariance quantilesstdevvariance NFraction)Decimal)groupby)bisect_leftbisect_right)hypotsqrtfabsexperftaulogfsum)
itemgetter)Counterc @ s e Zd ZdS )r N)__name__
__module____qualname__ r&