AlkantarClanX12

Your IP : 3.147.65.111


Current Path : /proc/self/root/opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python39/lib64/python3.9/__pycache__/statistics.cpython-39.opt-2.pyc

a

R�f���@s�gd�ZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddlm
Z
mZmZmZmZmZmZmZddlmZdd	lmZGd
d�de�ZdFdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dGdd�Z"dd�Z#dd �Z$d!d"�Z%d#d$�Z&d%d&�Z'd'd(�Z(d)d*�Z)dHd,d-�Z*d.d/�Z+d0d1�Z,d2d3d4�d5d6�Z-dId7d8�Z.dJd9d:�Z/dKd;d<�Z0dLd=d>�Z1dMd?d@�Z2dAdB�Z3zddCl4m3Z3Wne5�y�Yn0GdDdE�dE�Z6dS)N)�
NormalDist�StatisticsError�fmean�geometric_mean�
harmonic_mean�mean�median�median_grouped�median_high�
median_low�mode�	multimode�pstdev�	pvariance�	quantiles�stdev�variance�N��Fraction)�Decimal)�groupby)�bisect_left�bisect_right)�hypot�sqrt�fabs�exp�erf�tau�log�fsum)�
itemgetter)�Counterc@seZdZdS)rN)�__name__�
__module__�__qualname__�r&r&�//opt/alt/python39/lib64/python3.9/statistics.pyrusrcCs�d}t|�\}}||i}|j}ttt|��}t|t�D]@\}}	t||�}tt|	�D]"\}}|d7}||d�|||<qRq6d|vr�|d}
ntdd�t|�	��D��}
||
|fS)Nr�css|]\}}t||�VqdS�Nr)�.0�d�nr&r&r'�	<genexpr>��z_sum.<locals>.<genexpr>)
�_exact_ratio�get�_coerce�int�typer�map�sum�sorted�items)�data�start�countr,r+ZpartialsZpartials_get�T�typ�values�totalr&r&r'�_sum{s$
r?cCs,z
|��WSty&t�|�YS0dSr))Z	is_finite�AttributeError�mathZisfinite)�xr&r&r'�	_isfinite�s
rCcCs�||ur|S|tus|tur |S|tur,|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)r2�bool�
issubclassr�float�	TypeErrorr#)r;�S�msgr&r&r'r1�sr1cCs�znt|�tust|�tur$|��WSz|j|jfWWStyjz|��WYWStydYn0Yn0Wnttfy�|dfYS0d}t	|�
t|�j���dS)Nz0can't convert type '{}' to numerator/denominator)r3rFr�as_integer_ratio�	numerator�denominatorr@�
OverflowError�
ValueErrorrG�formatr#)rBrIr&r&r'r/�s
r/cCsnt|�|ur|St|t�r(|jdkr(t}z
||�WStyht|t�rb||j�||j�YS�Yn0dS)Nr()r3rEr2rLrFrGrrK)�valuer;r&r&r'�_convert�s

rQcCs.t||�}|t|�kr&|||kr&|St�dSr))r�lenrN)�arB�ir&r&r'�
_find_lteq
s
rUcCs>t|||d�}|t|�dkr6||d|kr6|dSt�dS)N)�lor()rrRrN)rS�lrBrTr&r&r'�
_find_rteqs rX�negative valueccs$|D]}|dkrt|��|VqdS)Nr)r)r=�errmsgrBr&r&r'�	_fail_negsr[cCsHt|�|urt|�}t|�}|dkr,td��t|�\}}}t|||�S)Nr(z%mean requires at least one data point)�iter�listrRrr?rQ)r8r,r;r>r:r&r&r'r'srcspzt|��Wn.ty:d��fdd�}t||��}Yn
0t|�}z
|�WStyjtd�d�Yn0dS)Nrc3s t|dd�D]\�}|VqdS)Nr()r9)�	enumerate)�iterablerB�r,r&r'r:Oszfmean.<locals>.countz&fmean requires at least one data point)rRrGr �ZeroDivisionErrorr)r8r:r>r&r`r'rAs	
rcCs6ztttt|���WSty0td�d�Yn0dS)NzGgeometric mean requires a non-empty dataset containing positive numbers)rrr4rrNr)r8r&r&r'r\s�rcCs�t|�|urt|�}d}t|�}|dkr2td��n<|dkrn|d}t|tjtf�rf|dkrbt|��|Std��z"t	dd�t
||�D��\}}}Wnty�YdS0t|||�S)Nz.harmonic mean does not support negative valuesr(z.harmonic_mean requires at least one data pointrzunsupported typecss|]}d|VqdS)r(Nr&�r*rBr&r&r'r-�r.z harmonic_mean.<locals>.<genexpr>)
r\r]rRr�
isinstance�numbersZRealrrGr?r[rarQ)r8rZr,rBr;r>r:r&r&r'ros$
"rcCs\t|�}t|�}|dkr td��|ddkr8||dS|d}||d||dSdS�Nr�no median for empty data�r(�r6rRr)r8r,rTr&r&r'r�s
rcCsLt|�}t|�}|dkr td��|ddkr8||dS||ddSdSrerh�r8r,r&r&r'r
�sr
cCs,t|�}t|�}|dkr td��||dS)Nrrfrgrhrir&r&r'r	�s
r	r(c
Cs�t|�}t|�}|dkr"td��n|dkr2|dS||d}||fD]}t|ttf�rFtd|��qFz||d}Wn&ty�t|�t|�d}Yn0t||�}t	|||�}|}||d}	|||d||	S)Nrrfr(rgzexpected number but got %r)
r6rRrrc�str�bytesrGrFrUrX)
r8Zintervalr,rB�obj�L�l1�l2Zcf�fr&r&r'r�s&

rcCsBtt|���d�}z|ddWSty<td�d�Yn0dS)Nr(rzno mode for empty data)r"r\�most_common�
IndexErrorr)r8Zpairsr&r&r'rs
rcCs@tt|����}tt|td�d�dgf�\}}tttd�|��S)Nr()�keyr)r"r\rq�nextrr!r]r4)r8ZcountsZmaxcountZ
mode_itemsr&r&r'r4s
r��	exclusive)r,�methodc
CsB|dkrtd��t|�}t|�}|dkr0td��|dkr�|d}g}td|�D]D}t|||�\}}||||||d||}	|�|	�qN|S|dk�r0|d}g}td|�D]r}|||}|dkr�dn||dkr�|dn|}||||}||d||||||}	|�|	�q�|Std|����dS)Nr(zn must be at least 1rgz"must have at least two data pointsZ	inclusivervzUnknown method: )rr6rR�range�divmod�appendrN)
r8r,rwZld�m�resultrT�jZdeltaZinterpolatedr&r&r'rks2$
$$rcs��dur,t�fdd�|D��\}}}||fSt|��t�fdd�|D��\}}}t�fdd�|D��\}}}||dt|�8}||fS)Nc3s|]}|�dVqdS�rgNr&rb��cr&r'r-�r.z_ss.<locals>.<genexpr>c3s|]}|�dVqdSr~r&rbrr&r'r-�r.c3s|]}|�VqdSr)r&rbrr&r'r-�r.rg)r?rrR)r8r�r;r>r:�UZtotal2Zcount2r&rr'�_ss�sr�cCsLt|�|urt|�}t|�}|dkr,td��t||�\}}t||d|�S)Nrgz*variance requires at least two data pointsr(�r\r]rRrr�rQ)r8�xbarr,r;�ssr&r&r'r�s&rcCsHt|�|urt|�}t|�}|dkr,td��t||�\}}t|||�S)Nr(z*pvariance requires at least one data pointr�)r8�mur,r;r�r&r&r'r�s#rcCs6t||�}z
|��WSty0t�|�YS0dSr))rrr@rA)r8r��varr&r&r'rs
	

rcCs6t||�}z
|��WSty0t�|�YS0dSr))rrr@rA)r8r�r�r&r&r'r
$s
	

r
cCs|d}t|�dkr�d||}d|d|d|d|d|d	|d
|d|}d|d
|d|d|d|d|d|d}||}|||S|dkr�|nd|}tt|��}|dk�r^|d}d|d|d|d|d|d|d|d}d|d |d!|d"|d#|d$|d%|d}n�|d}d&|d'|d(|d)|d*|d+|d,|d-}d.|d/|d0|d1|d2|d3|d4|d}||}|dk�r�|}|||S)5N��?g333333�?g��Q��?g^�}o)��@g�E.k�R�@g ��Ul�@g*u��>l�@g�N����@g�"]Ξ@gnC���`@gu��@giK��~j�@gv��|E�@g��d�|1�@gfR��r��@g��u.2�@g���~y�@g�n8(E@��?�g@g�������?g鬷�ZaI?gg�El�D�?g7\�����?g�uS�S�?g�=�.
@gj%b�@g���Hw�@gjR�e�?g�9dh?
>g('߿��A?g��~z �?g@�3��?gɅ3��?g3fR�x�?gI�F��l@g����t��>g*�Y��n�>gESB\T?g�N;A+�?g�UR1��?gE�F���?gP�n��@g&�>���@g����i�<g�@�F�>g�tcI,\�>g�ŝ���I?g*F2�v�?g�C4�?g��O�1�?)rrr)�pr��sigma�q�rZnumZdenrBr&r&r'�_normal_dist_inv_cdf7sd���������������������������
��������������������������	��������������������������
r�)r�c@seZdZddd�Zd9dd�Zedd	��Zd
d�dd
�Zdd�Zdd�Z	dd�Z
d:dd�Zdd�Zdd�Z
edd��Zedd��Zedd ��Zed!d"��Zed#d$��Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�ZeZd1d2�ZeZd3d4�Zd5d6�Zd7d8�Zd
S);rz(Arithmetic mean of a normal distributionz+Standard deviation of a normal distribution)�_mu�_sigmar�r�cCs(|dkrtd��t|�|_t|�|_dS)Nr�zsigma must be non-negative)rrFr�r�)�selfr�r�r&r&r'�__init__�s
zNormalDist.__init__cCs.t|ttf�st|�}t|�}||t||��Sr))rcr]�tuplerr)�clsr8r�r&r&r'�from_samples�szNormalDist.from_samplesN)�seedcsB|durtjn
t�|�j�|j|j�����fdd�t|�D�S)Ncsg|]}�����qSr&r&�r*rT��gaussr�r�r&r'�
<listcomp>�r.z&NormalDist.samples.<locals>.<listcomp>)�randomr�ZRandomr�r�rx)r�r,r�r&r�r'�samples�szNormalDist.samplescCs<|jd}|std��t||jdd|�tt|�S)N�@z$pdf() not defined when sigma is zerog�)r�rrr�rr)r�rBrr&r&r'�pdf�s
zNormalDist.pdfcCs2|jstd��ddt||j|jtd��S)Nz$cdf() not defined when sigma is zeror�r�r�)r�rrr�r�r�rBr&r&r'�cdf�szNormalDist.cdfcCs:|dks|dkrtd��|jdkr*td��t||j|j�S)Nr�r�z$p must be in the range 0.0 < p < 1.0z-cdf() not defined when sigma at or below zero)rr�r�r�)r�r�r&r&r'�inv_cdf�s


zNormalDist.inv_cdfrucs��fdd�td��D�S)Ncsg|]}��|���qSr&)r�r��r,r�r&r'r��r.z(NormalDist.quantiles.<locals>.<listcomp>r()rx)r�r,r&r�r'r�s	zNormalDist.quantilescCst|t�std��||}}|j|jf|j|jfkr>||}}|j|j}}|rT|s\td��||}t|j|j�}|s�dt|d|jt	d��S|j||j|}|j|jt	|d|t
||��}	||	|}
||	|}dt|�|
�|�|
��t|�|�|�|��S)Nz$Expected another NormalDist instancez(overlap() not defined when sigma is zeror�r�)rcrrGr�r�rrrrrrr�)r��other�X�YZX_varZY_varZdvZdmrS�b�x1�x2r&r&r'�overlap�s"


(zNormalDist.overlapcCs|jstd��||j|jS)Nz'zscore() not defined when sigma is zero)r�rr�r�r&r&r'�zscore�szNormalDist.zscorecCs|jSr)�r��r�r&r&r'r�szNormalDist.meancCs|jSr)r�r�r&r&r'rszNormalDist.mediancCs|jSr)r�r�r&r&r'rszNormalDist.modecCs|jSr)�r�r�r&r&r'rszNormalDist.stdevcCs
|jdS)Nr�r�r�r&r&r'rszNormalDist.variancecCs8t|t�r&t|j|jt|j|j��St|j||j�Sr)�rcrr�rr��r�r�r&r&r'�__add__s

zNormalDist.__add__cCs8t|t�r&t|j|jt|j|j��St|j||j�Sr)r�r�r&r&r'�__sub__'s

zNormalDist.__sub__cCst|j||jt|��Sr)�rr�r�rr�r&r&r'�__mul__5szNormalDist.__mul__cCst|j||jt|��Sr)r�r�r&r&r'�__truediv__=szNormalDist.__truediv__cCst|j|j�Sr)�rr�r��r�r&r&r'�__pos__EszNormalDist.__pos__cCst|j|j�Sr)r�r�r&r&r'�__neg__IszNormalDist.__neg__cCs
||Sr)r&r�r&r&r'�__rsub__OszNormalDist.__rsub__cCs&t|t�stS|j|jko$|j|jkSr))rcr�NotImplementedr�r�r�r&r&r'�__eq__Us
zNormalDist.__eq__cCst|j|jf�Sr))�hashr�r�r�r&r&r'�__hash__[szNormalDist.__hash__cCs t|�j�d|j�d|j�d�S)Nz(mu=z, sigma=�))r3r#r�r�r�r&r&r'�__repr___szNormalDist.__repr__)r�r�)ru) r#r$r%�	__slots__r��classmethodr�r�r�r�r�rr�r��propertyrrrrrr�r�r�r�r�r��__radd__r��__rmul__r�r�r�r&r&r&r'r�sF�


"




r)r)rY)r()N)N)N)N)N)7�__all__rArdr�Z	fractionsr�decimalr�	itertoolsrZbisectrrrrrrrrrr �operatorr!�collectionsr"rNrr?rCr1r/rQrUrXr[rrrrrr
r	rrrrr�rrrr
r�Z_statistics�ImportErrorrr&r&r&r'�<module>SsR(
: 

/
778

/
,

K