Your IP : 3.14.249.191


Current Path : /lib64/python3.6/__pycache__/
Upload File :
Current File : //lib64/python3.6/__pycache__/statistics.cpython-36.opt-2.pyc

3


 \�P�@s@dddddddddd	d
dgZdd
lZdd
lZdd
lZdd
lZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
Gdd�de�Zd4dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd5d$d%�Zd&d	�Zd'd�Zd(d�Zd)d�Zd*d�Zd6d,d�Zd-d
�Zd7d.d/�Z d8d0d�Z!d9d1d�Z"d:d2d�Z#d;d3d�Z$d
S)<�StatisticsError�pstdev�	pvariance�stdev�variance�median�
median_low�median_high�median_grouped�mean�mode�
harmonic_mean�N)�Fraction)�Decimal)�groupby�chain)�bisect_left�bisect_rightc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�"/usr/lib64/python3.6/statistics.pyrcscCs�d}t|�\}}||i}|j}ttt|��}xRt|t�D]D\}}	t||�}x0tt|	�D]"\}}|d7}||d�|||<qVWq8Wd|kr�|d}
ntdd�t|j	��D��}
||
|fS)Nr
�css|]\}}t||�VqdS)N)r)�.0�d�nrrr�	<genexpr>�sz_sum.<locals>.<genexpr>)
�_exact_ratio�get�_coerce�int�typer�map�sum�sorted�items)�data�start�countrrZpartialsZpartials_get�T�typ�values�totalrrr�_sumis$
r.cCs(y|j�Stk
r"tj|�SXdS)N)Z	is_finite�AttributeError�mathZisfinite)�xrrr�	_isfinite�sr2cCs�||kr|S|tks|tkr |S|tkr,|St||�r:|St||�rH|St|t�rV|St|t�rd|St|t�r|t|t�r||St|t�r�t|t�r�|Sd}t||j|jf��dS)Nz"don't know how to coerce %s and %s)r!�bool�
issubclassr�float�	TypeErrorr)r*�S�msgrrrr �s(



r cCs�ydt|�tkst|�tkr"|j�Sy|j|jfStk
r`y|j�Stk
rZYnXYnXWnttfk
r�|dfSXd}t	|j
t|�j���dS)Nz0can't convert type '{}' to numerator/denominator)r"r5r�as_integer_ratio�	numerator�denominatorr/�
OverflowError�
ValueErrorr6�formatr)r1r8rrrr�s
rcCsjt|�|kr|St|t�r(|jdkr(t}y||�Stk
rdt|t�r^||j�||j�S�YnXdS)Nr)r"r4r!r;r5r6rr:)�valuer*rrr�_convert�s
r@cCs`tjt|��j�}|s|S|dd}x4tdt|��D]"}||d|kr6|d|�}Pq6W|S)Nr
r)�collections�Counter�iter�most_common�range�len)r'�tableZmaxfreq�irrr�_counts�srIcCs.t||�}|t|�kr&|||kr&|St�dS)N)rrFr=)�ar1rHrrr�
_find_lteq	s
rKcCs>t|||d�}|t|�dkr6||d|kr6|dSt�dS)N)�lor)rrFr=)rJ�lr1rHrrr�
_find_rteqs rN�negative valueccs(x"|D]}|dkrt|��|VqWdS)Nr
)r)r,�errmsgr1rrr�	_fail_negs
rQcCsHt|�|krt|�}t|�}|dkr,td��t|�\}}}t|||�S)Nrz%mean requires at least one data point)rC�listrFrr.r@)r'rr*r-r)rrrr
#scCs�t|�|krt|�}d}t|�}|dkr2td��n<|dkrn|d}t|tjtf�rf|dkrbt|��|Std��y"t	dd�t
||�D��\}}}Wntk
r�dSXt|||�S)Nz.harmonic mean does not support negative valuesrz.harmonic_mean requires at least one data pointr
zunsupported typecss|]}d|VqdS)rNr)rr1rrrrdsz harmonic_mean.<locals>.<genexpr>)
rCrRrFr�
isinstance�numbersZRealrr6r.rQ�ZeroDivisionErrorr@)r'rPrr1r*r-r)rrrr=s$
"cCs\t|�}t|�}|dkr td��|ddkr8||dS|d}||d||dSdS)Nr
zno median for empty data�r)r%rFr)r'rrHrrrrls
cCsLt|�}t|�}|dkr td��|ddkr8||dS||ddSdS)Nr
zno median for empty datarVr)r%rFr)r'rrrrr�scCs,t|�}t|�}|dkr td��||dS)Nr
zno median for empty datarV)r%rFr)r'rrrrr�s
rc
Cs�t|�}t|�}|dkr"td��n|dkr2|dS||d}x*||fD]}t|ttf�rHtd|��qHWy||d}Wn(tk
r�t|�t|�d}YnXt||�}t	|||�}|}||d}	|||d||	S)Nr
zno median for empty datarrVzexpected number but got %r)
r%rFrrS�str�bytesr6r5rKrN)
r'Zintervalrr1�obj�L�l1�l2Zcf�frrrr	�s&

cCsBt|�}t|�dkr |ddS|r6tdt|���ntd��dS)Nrr
z.no unique mode; found %d equally common valueszno mode for empty data)rIrFr)r'rGrrrr�scsd�dkrt|��t�fdd�|D��\}}}t�fdd�|D��\}}}||dt|�8}||fS)Nc3s|]}|�dVqdS)rVNr)rr1)�crrrsz_ss.<locals>.<genexpr>c3s|]}|�VqdS)Nr)rr1)r^rrrsrV)r
r.rF)r'r^r*r-r)�UZtotal2Zcount2r)r^r�_sssr`cCsLt|�|krt|�}t|�}|dkr,td��t||�\}}t||d|�S)NrVz*variance requires at least two data pointsr)rCrRrFrr`r@)r'�xbarrr*�ssrrrr"s&cCsHt|�|krt|�}t|�}|dkr,td��t||�\}}t|||�S)Nrz*pvariance requires at least one data point)rCrRrFrr`r@)r'�murr*rbrrrrQs'cCs2t||�}y|j�Stk
r,tj|�SXdS)N)r�sqrtr/r0)r'ra�varrrrr�s
	
cCs2t||�}y|j�Stk
r,tj|�SXdS)N)rrdr/r0)r'rcrerrrr�s
	
)r
)rO)r)N)N)N)N)N)%�__all__rAZdecimalr0rTZ	fractionsrr�	itertoolsrrZbisectrrr=rr.r2r rr@rIrKrNrQr
rrrrr	rr`rrrrrrrr�<module>OsB

: 

/
7*

/
0


?>