AlkantarClanX12

Your IP : 18.223.213.76


Current Path : /usr/lib64/python3.8/__pycache__/
Upload File :
Current File : //usr/lib64/python3.8/__pycache__/statistics.cpython-38.opt-2.pyc

U

e5d
��@sjdddddddddd	d
ddd
dddgZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddlm
Z
mZmZmZmZmZmZmZddlmZddlmZGdd�de�Zdcdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Z d'd(�Z!ddd*d+�Z"d,d�Z#d-d�Z$d.d�Z%d/d�Z&d0d�Z'd1d	�Z(d2d�Z)ded4d�Z*d5d
�Z+d6d�Z,d7d8d9�d:d�Z-dfd;d<�Z.dgd=d�Z/dhd>d
�Z0did?d�Z1djd@d�Z2dAdB�Z3GdCd�d�Z4zddDl5m3Z3Wne6k
�r�YnXe7dEk�rfddFlm8Z8ddGlm9Z9m:Z:m;Z;m<Z<ddHlm=Z=ddl>Z>e4dIdJ�Z?e4dKdL�Z@dMZAe?�BeA�ZCe@�BeA�ZDe9e:fD]<ZEeFdNeEj7�dO��eFeEe?e@��eFe4�GeHeEeCeD����qNdPZIe9e:e;e<fD]@ZEeFdNeEj7�dQ��eFeEe?eI��eFe4�GeHeEeCe=eI�����q�dRZIe9e:e;fD]@ZEeFdSeEj7�dT��eFeEeIe?��eFe4�GeHeEe=eI�eC����q�dUdV�ZJe4dWdX�ZKe4dYdZ�ZLd[ZMdMZAe4�Gd\d]�eK�BeA�D��ZNeJeKeMeN�e4�Gd^d]�eK�BeA�D��ZNeJeKeMeN�e4�Gd_d]�eK�BeA�D��ZNeJeKeMeN�e4�Gd`d]�eK�BeA�D��ZNeJeKeMeN�e4�Gdad]�eOeK�BeA�eL�BeA��D��ZNeJeKeLeN�e4�Gdbd]�eOeK�BeA�eL�BeA��D��ZNeJeKeLeN�eFe>�P��dS)k�
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&�"/usr/lib64/python3.8/statistics.pyruscCs�d}t|�\}}||i}|j}ttt|��}t|t�D]@\}}	t||�}tt|	�D]"\}}|d7}||d�|||<qRq6d|kr�|d}
ntdd�t|�	��D��}
||
|fS)Nr�css|]\}}t||�VqdS�Nr)�.0�d�nr&r&r'�	<genexpr>�sz_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
|��WStk
r(t�|�YSXdSr))Z	is_finite�AttributeError�mathZisfinite)�xr&r&r'�	_isfinite�s
rBcCs�||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)r1�bool�
issubclassr�float�	TypeErrorr#)r:�S�msgr&r&r'r0�s(



r0cCs�zrt|�tkst|�tkr$|��WSz|j|jfWWStk
rnz|��WYWStk
rhYnXYnXWn ttfk
r�|dfYSXd}t	|�
t|�j���dS)Nz0can't convert type '{}' to numerator/denominator)r2rEr�as_integer_ratio�	numerator�denominatorr?�
OverflowError�
ValueErrorrF�formatr#)rArHr&r&r'r.�s
r.cCspt|�|kr|St|t�r(|jdkr(t}z
||�WStk
rjt|t�rd||j�||j�YS�YnXdS)Nr()r2rDr1rKrErFrrJ)�valuer:r&r&r'�_convert�s

rPcCs.t||�}|t|�kr&|||kr&|St�dSr))r�lenrM)�arA�ir&r&r'�
_find_lteq
s
rTcCs>t|||d�}|t|�dkr6||d|kr6|dSt�dS)N)�lor()rrQrM)rR�lrArSr&r&r'�
_find_rteqs rW�negative valueccs$|D]}|dkrt|��|VqdS)Nr)r)r<�errmsgrAr&r&r'�	_fail_negsrZcCsHt|�|krt|�}t|�}|dkr,td��t|�\}}}t|||�S)Nr(z%mean requires at least one data point)�iter�listrQrr>rP)r7r,r:r=r9r&r&r'r'scstzt|��Wn0tk
r<d��fdd�}t||��}Yn
Xt|�}z
|�WStk
rntd�d�YnXdS)Nrc3s t|dd�D]\�}|VqdS)Nr()r8)�	enumerate)�iterablerA�r,r&r'r9Oszfmean.<locals>.countz&fmean requires at least one data point)rQrFr �ZeroDivisionErrorr)r7r9r=r&r_r'rAs	
cCs8ztttt|���WStk
r2td�d�YnXdS)NzHgeometric mean requires a non-empty dataset  containing positive numbers)rrr3rrMr)r7r&r&r'r\s�cCs�t|�|krt|�}d}t|�}|dkr2td��n<|dkrn|d}t|tjtf�rf|dkrbt|��|Std��z"t	dd�t
||�D��\}}}Wntk
r�YdSXt|||�S)Nz.harmonic mean does not support negative valuesr(z.harmonic_mean requires at least one data pointrzunsupported typecss|]}d|VqdS)r(Nr&�r*rAr&r&r'r-�sz harmonic_mean.<locals>.<genexpr>)
r[r\rQr�
isinstance�numbersZRealrrFr>rZr`rP)r7rYr,rAr:r=r9r&r&r'ros$
"cCs\t|�}t|�}|dkr td��|ddkr8||dS|d}||d||dSdS�Nr�no median for empty data�r(�r5rQr)r7r,rSr&r&r'r�s
cCsLt|�}t|�}|dkr td��|ddkr8||dS||ddSdSrdrg�r7r,r&r&r'r
�scCs,t|�}t|�}|dkr td��||dS)Nrrerfrgrhr&r&r'r	�s
r(c
Cs�t|�}t|�}|dkr"td��n|dkr2|dS||d}||fD]}t|ttf�rFtd|��qFz||d}Wn(tk
r�t|�t|�d}YnXt||�}t	|||�}|}||d}	|||d||	S)Nrrer(rfzexpected number but got %r)
r5rQrrb�str�bytesrFrErTrW)
r7Zintervalr,rA�obj�L�l1�l2Zcf�fr&r&r'r�s&

cCsHt|�}t|��d�}z|ddWStk
rBtd�d�YnXdS)Nr(rzno mode for empty data)r[r"�most_common�
IndexErrorr)r7Zpairsr&r&r'rscCs@tt|����}tt|td�d�dgf�\}}tttd�|��S)Nr()�keyr)r"r[rp�nextrr!r\r3)r7ZcountsZmaxcountZ
mode_itemsr&r&r'r5s
��	exclusive)r,�methodc
CsL|dkrtd��t|�}t|�}|dkr0td��|dkr�|d}g}td|�D]N}|||}||||}||||||d||}	|�|	�qN|S|dk�r:|d}g}td|�D]r}|||}|dkr�dn||dkr�|dn|}||||}||d||||||}	|�|	�q�|Std|����dS)Nr(zn must be at least 1rfz"must have at least two data pointsZ	inclusiveruzUnknown method: )rr5rQ�range�appendrM)
r7r,rvZld�m�resultrS�jZdeltaZinterpolatedr&r&r'rls4$
$$cs��dk	r,t�fdd�|D��\}}}||fSt|��t�fdd�|D��\}}}t�fdd�|D��\}}}||dt|�8}||fS)Nc3s|]}|�dVqdS�rfNr&ra��cr&r'r-�sz_ss.<locals>.<genexpr>c3s|]}|�dVqdSr|r&rar}r&r'r-�sc3s|]}|�VqdSr)r&rar}r&r'r-�srf)r>rrQ)r7r~r:r=r9�UZtotal2Zcount2r&r}r'�_ss�sr�cCsLt|�|krt|�}t|�}|dkr,td��t||�\}}t||d|�S)Nrfz*variance requires at least two data pointsr(�r[r\rQrr�rP)r7�xbarr,r:�ssr&r&r'r�s&cCsHt|�|krt|�}t|�}|dkr,td��t||�\}}t|||�S)Nr(z*pvariance requires at least one data pointr�)r7�mur,r:r�r&r&r'r�s#cCs8t||�}z
|��WStk
r2t�|�YSXdSr))rrr?r@)r7r��varr&r&r'rs
	

cCs8t||�}z
|��WStk
r2t�|�YSXdSr))rrr?r@)r7r�r�r&r&r'r
&s
	

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�rZnumZdenrAr&r&r'�_normal_dist_inv_cdf9sd���������������������������
��������������������������	��������������������������
r�c@s�eZdZddd�Zd7dd�Zedd	��Zd
d�dd
�Zdd�Zdd�Z	dd�Z
d8dd�Zdd�Ze
dd��Ze
dd��Ze
dd��Ze
dd ��Ze
d!d"��Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�ZeZd/d0�ZeZd1d2�Zd3d4�Zd5d6�Zd
S)9rz(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)rrEr�r�)�selfr�r�r&r&r'�__init__�s
zNormalDist.__init__cCs.t|ttf�st|�}t|�}||t||��Sr))rbr\�tuplerr)�clsr7r�r&r&r'�from_samples�szNormalDist.from_samplesN)�seedcsB|dkrtjn
t�|�j�|j|j�����fdd�t|�D�S)Ncsg|]}�����qSr&r&�r*rS��gaussr�r�r&r'�
<listcomp>�sz&NormalDist.samples.<locals>.<listcomp>)�randomr�ZRandomr�r�rw)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�rArr&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�rAr&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_cdfrtcs��fdd�td��D�S)Ncsg|]}��|���qSr&)r�r��r,r�r&r'r��sz(NormalDist.quantiles.<locals>.<listcomp>r()rw)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�)rbrrFr�r�rrrrrrr�)r��other�X�YZX_varZY_varZdvZdmrR�b�x1�x2r&r&r'�overlap�s"


(zNormalDist.overlapcCs|jSr)�r��r�r&r&r'r�szNormalDist.meancCs|jSr)r�r�r&r&r'r�szNormalDist.mediancCs|jSr)r�r�r&r&r'r�szNormalDist.modecCs|jSr)�r�r�r&r&r'r�szNormalDist.stdevcCs
|jdS)Nr�r�r�r&r&r'rszNormalDist.variancecCs8t|t�r&t|j|jt|j|j��St|j||j�Sr)�rbrr�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__%szNormalDist.__mul__cCst|j||jt|��Sr)r�r�r&r&r'�__truediv__-szNormalDist.__truediv__cCst|j|j�Sr)�rr�r��r�r&r&r'�__pos__5szNormalDist.__pos__cCst|j|j�Sr)r�r�r&r&r'�__neg__9szNormalDist.__neg__cCs
||Sr)r&r�r&r&r'�__rsub__?szNormalDist.__rsub__cCs&t|t�stS|j|jko$|j|jkSr))rbr�NotImplementedr�r�r�r&r&r'�__eq__Es
zNormalDist.__eq__cCst|j|jf�Sr))�hashr�r�r�r&r&r'�__hash__KszNormalDist.__hash__cCs t|�j�d|j�d|j�d�S)Nz(mu=z, sigma=�))r2r#r�r�r�r&r&r'�__repr__OszNormalDist.__repr__)r�r�)rt)r#r$r%�	__slots__r��classmethodr�r�r�r�r�rr��propertyrrrrrr�r�r�r�r�r��__radd__r��__rmul__r�r�r�r&r&r&r'r�sD�


"




)r��__main__)�isclose)�add�sub�mul�truediv)�repeat�
�����i��z
Test z with another NormalDist:�z with a constant:�z
Test constant with �:cCsdSr)r&)�G1�G2r&r&r'�assert_closesr�i�����I��/g`@@cCsg|]}|t�qSr&��srar&r&r'r��sr�cCsg|]}|t�qSr&r�rar&r&r'r��scCsg|]}|t�qSr&r�rar&r&r'r��scCsg|]}|t�qSr&r�rar&r&r'r��scCsg|]\}}||�qSr&r&�r*rA�yr&r&r'r��scCsg|]\}}||�qSr&r&r�r&r&r'r��s)r)rX)r()N)N)N)N)N)Q�__all__r@rcr�Z	fractionsrZdecimalr�	itertoolsrZbisectrrrrrrrrrr �operatorr!�collectionsr"rMrr>rBr0r.rPrTrWrZrrrrrr
r	rrrrr�rrrr
r�rZ_statistics�ImportErrorr#r�r�r�r�r�r�ZdoctestZg1Zg2r,r�r�r��func�printr�r3Zconstr�r�r�r�rG�zipZtestmodr&r&r&r'�<module>Ts��(
: 

/
779

/
,

JQ






�
�