AlkantarClanX12

Your IP : 18.227.114.218


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/statistics.cpython-310.opt-2.pyc

o

6��fŨ�@s�	gd�ZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
ddlmZmZmZmZmZmZmZmZddlmZdd	lmZmZGd
d�de�Zdd
�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dNdd�Z$dd�Z%dd �Z&d!d"�Z'dOd#d$�Z(d%d&�Z)d'd(�Z*d)d*�Z+dPd,d-�Z,d.d/�Z-d0d1�Z.d2d3d4�d5d6�Z/dOd7d8�Z0dOd9d:�Z1dOd;d<�Z2dOd=d>�Z3dOd?d@�Z4dAdB�Z5dCdD�Z6edEdF�Z7dGdH�Z8dIdJ�Z9zddKl:m9Z9Wn	e;y�YnwGdLdM�dM�Z<dS)Q)�
NormalDist�StatisticsError�correlation�
covariance�fmean�geometric_mean�
harmonic_mean�linear_regression�mean�median�median_grouped�median_high�
median_low�mode�	multimode�pstdev�	pvariance�	quantiles�stdev�variance�N��Fraction)�Decimal)�groupby�repeat)�bisect_left�bisect_right)�hypot�sqrt�fabs�exp�erf�tau�log�fsum)�
itemgetter)�Counter�
namedtuplec@seZdZdS)rN)�__name__�
__module__�__qualname__�r+r+�1/opt/alt/python310/lib64/python3.10/statistics.pyr�src
Cs�	d}i}|j}t}t|t�D] \}}t||�}tt|�D]\}}|d7}||d�|||<qqd|vr9|d}	ntdd�|��D��}	||	|fS)Nr�cs��|]
\}}t||�VqdS�Nr��.0�d�nr+r+r,�	<genexpr>���z_sum.<locals>.<genexpr>)	�get�intr�type�_coerce�map�_exact_ratio�sum�items)
�data�count�partialsZpartials_get�T�typ�valuesr3r2�totalr+r+r,�_sum�s
�

rEcCs(z|��WStyt�|�YSwr/)Z	is_finite�AttributeError�mathZisfinite)�xr+r+r,�	_isfinite�s

�rIcCs�	||ur|S|tus|tur|S|tur|St||�r|St||�r%|St|t�r,|St|t�r3|St|t�r?t|t�r?|St|t�rKt|t�rK|Sd}t||j|jf��)Nz"don't know how to coerce %s and %s)r7�bool�
issubclassr�float�	TypeErrorr()rA�S�msgr+r+r,r9�s
r9c	Cst	z|��WStyYnttfy|dfYSwz|j|jfWSty9dt|�j�d�}t|��w)Nzcan't convert type 'z' to numerator/denominator)	�as_integer_ratiorF�
OverflowError�
ValueError�	numerator�denominatorr8r(rM)rHrOr+r+r,r;�s
��r;cCsh	t|�|ur	|St|t�r|jdkrt}z||�WSty3t|t�r2||j�||j�YS�w)Nr-)r8rKr7rTrLrMrrS)�valuerAr+r+r,�_converts

�rVcCs,	t||�}|t|�kr|||kr|St�r/)r�lenrR)�arH�ir+r+r,�
_find_lteqs

rZcCs<	t|||d�}|t|�dkr||d|kr|dSt�)N)�lor-)rrWrR)rX�lrHrYr+r+r,�
_find_rteq"s
 r]�negative valueccs(�	|D]
}|dkrt|��|VqdS)Nr)r)rC�errmsgrHr+r+r,�	_fail_neg*s��r`cCsJ	t|�|urt|�}t|�}|dkrtd��t|�\}}}t|||�S)Nr-z%mean requires at least one data point)�iter�listrWrrErV)r>r3rArDr?r+r+r,r	4sr	csj	zt|��Wntyd��fdd�}t||��}Ynwt|�}z|�WSty4td�d�w)Nrc3s"�t|dd�D]\�}|VqdS)Nr-)�start)�	enumerate)�iterablerH�r3r+r,r?\s��zfmean.<locals>.countz&fmean requires at least one data point)rWrMr$�ZeroDivisionErrorr)r>r?rDr+rfr,rNs�	

�rcCs0	z
tttt|���WStytd�d�w)NzGgeometric mean requires a non-empty dataset containing positive numbers)r rr:r#rRr)r>r+r+r,ris��rc
Cs4	t|�|urt|�}d}t|�}|dkrtd��|dkr;|dur;|d}t|tjtf�r7|dkr5t|��|Std��|durGt	d|�}|}n#t|�|urQt|�}t|�|kr[td��t
dd�t||�D��\}}}zt||�}t
d	d�t||�D��\}}}	Wn
t
y�YdSw|dkr�td
��t|||�S)Nz.harmonic mean does not support negative valuesr-z.harmonic_mean requires at least one data pointrzunsupported typez*Number of weights does not match data sizecss�|]}|VqdSr/r+)r1�wr+r+r,r4�s�z harmonic_mean.<locals>.<genexpr>css$�|]
\}}|r||ndVqdS)rNr+)r1rhrHr+r+r,r4���"zWeighted sum must be positive)rarbrWr�
isinstance�numbersZRealrrMrrEr`�ziprgrV)
r>Zweightsr_r3rHZsum_weights�_rArDr?r+r+r,r|s>

"�rcCsZ	t|�}t|�}|dkrtd��|ddkr||dS|d}||d||dS�Nr�no median for empty data�r-��sortedrWr)r>r3rYr+r+r,r
�sr
cCsJ	t|�}t|�}|dkrtd��|ddkr||dS||ddSrnrq�r>r3r+r+r,r
�sr
cCs.	t|�}t|�}|dkrtd��||dS)Nrrorprqrsr+r+r,r�srr-c
Cs�	t|�}t|�}|dkrtd��|dkr|dS||d}||fD]}t|ttf�r2td|��q#z||d}WntyNt|�t|�d}Ynwt||�}t	|||�}|}||d}	|||d||	S)Nrror-rpzexpected number but got %r)
rrrWrrj�str�bytesrMrLrZr])
r>Zintervalr3rH�obj�L�l1�l2Zcf�fr+r+r,r�s,��
rcCs<	tt|���d�}z|ddWStytd�d�w)Nr-rzno mode for empty data)r&ra�most_common�
IndexErrorr)r>Zpairsr+r+r,r,s
�rcCsB	tt|����}tt|td�d�dgf�\}}tttd�|��S)Nr-)�keyr)r&rar{�nextrr%rbr:)r>ZcountsZmaxcountZ
mode_itemsr+r+r,rJsr��	exclusive)r3�methodc
Cs>	|dkr	td��t|�}t|�}|dkrtd��|dkrM|d}g}td|�D]"}t|||�\}}||||||d||}	|�|	�q(|S|dkr�|d}g}td|�D]9}|||}|dkrjdn||dkrt|dn|}||||}||d||||||}	|�|	�q\|Std|����)Nr-zn must be at least 1rpz"must have at least two data pointsZ	inclusiver�zUnknown method: )rrrrW�range�divmod�appendrR)
r>r3r�Zld�m�resultrY�jZdeltaZinterpolatedr+r+r,r�s4$$$rcs�	�durt�fdd�|D��\}}}||fSt|�\}}}||��\}}t�}tt|�D]\}}	|||	|}
|	|}||||
|
7<q.d|vrW|d}||fStdd�|��D��}||fS)Nc3��|]	}|�dVqdS)rpNr+)r1rH��cr+r,r4���z_ss.<locals>.<genexpr>csr.r/rr0r+r+r,r4�r5)rErPr&r:r;r<r=)r>r�rArDr?Zmean_nZmean_dr@r3r2Zdiff_nZdiff_dr+r�r,�_ss�s �r�cCsN	t|�|urt|�}t|�}|dkrtd��t||�\}}t||d|�S)Nrpz*variance requires at least two data pointsr-�rarbrWrr�rV)r>�xbarr3rA�ssr+r+r,r�s%rcCsJ	t|�|urt|�}t|�}|dkrtd��t||�\}}t|||�S)Nr-z*pvariance requires at least one data pointr�)r>�mur3rAr�r+r+r,rs"rcC�4	t||�}z|��WStyt�|�YSwr/)rrrFrG)r>r��varr+r+r,r0�

�rcCr�r/)rrrFrG)r>r�r�r+r+r,rCr�rcsp	t|�}t|�|krtd��|dkrtd��t|�|�t|�|�t��fdd�t||�D��}||dS)NzDcovariance requires that both inputs have same number of data pointsrpz,covariance requires at least two data pointsc3�$�|]
\}}|�|�VqdSr/r+�r1�xi�yi�r��ybarr+r,r4urizcovariance.<locals>.<genexpr>r-)rWrr$rl)rH�yr3�sxyr+r�r,r]srcs�	t|�}t|�|krtd��|dkrtd��t|�|�t|�|�t��fdd�t||�D��}t�fdd�|D��}t�fdd�|D��}z	|t||�WSty\td��w)	NzEcorrelation requires that both inputs have same number of data pointsrpz-correlation requires at least two data pointsc3r�r/r+r�r�r+r,r4�rizcorrelation.<locals>.<genexpr>c3r���@Nr+�r1r��r�r+r,r4�r�c3r�r�r+)r1r�)r�r+r,r4�r�z&at least one of the inputs is constant)rWrr$rlrrg)rHr�r3r��sxxZsyyr+r�r,rys �r�LinearRegression��slope�	interceptcs�	t|�}t|�|krtd��|dkrtd��t|�|�t|�|�t��fdd�t||�D��}t�fdd�|D��}z||}WntyNtd��w�|�}t||d�S)	NzKlinear regression requires that both inputs have same number of data pointsrpz3linear regression requires at least two data pointsc3r�r/r+r�r�r+r,r4�riz$linear_regression.<locals>.<genexpr>c3r�r�r+r�r�r+r,r4�r�z
x is constantr�)rWrr$rlrgr�)rHr�r3r�r�r�r�r+r�r,r�s"�rcCs�|d}t|�dkrXd||}d|d|d|d|d|d	|d
|d|}d|d
|d|d|d|d|d|d}||}|||S|dkr^|nd|}tt|��}|dkr�|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}||}|dkr�|}|||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�rZnumZdenrHr+r+r,�_normal_dist_inv_cdf�sd�����������������������������������������������������	��������������������������r�)r�c@seZdZ	ddd�Zd=dd�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�Zd9d:�Z d;d<�Z!d
S)?rz(Arithmetic mean of a normal distributionz+Standard deviation of a normal distribution��_mu�_sigmar�r�cCs*	|dkr	td��t|�|_t|�|_dS)Nr�zsigma must be non-negative)rrLr�r�)�selfr�r�r+r+r,�__init__%s

zNormalDist.__init__cCs0	t|ttf�st|�}t|�}||t||��Sr/)rjrb�tuplerr)�clsr>r�r+r+r,�from_samples,s
zNormalDist.from_samplesN)�seedcsD	|durtjnt�|�j�|j|j�����fdd�t|�D�S)Ncsg|]}�����qSr+r+�r1rY��gaussr�r�r+r,�
<listcomp>8sz&NormalDist.samples.<locals>.<listcomp>)�randomr�ZRandomr�r�r�)r�r3r�r+r�r,�samples4szNormalDist.samplescCs>	|jd}|std��t||jdd|�tt|�S)Nr�z$pdf() not defined when sigma is zerog�)r�rr r�rr")r�rHrr+r+r,�pdf:s

&zNormalDist.pdfcCs4	|jstd��ddt||j|jtd��S)Nz$cdf() not defined when sigma is zeror�r�r�)r�rr!r�r�r�rHr+r+r,�cdfAs$zNormalDist.cdfcCs<	|dks	|dkr
td��|jdkrtd��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_cdfGs	
zNormalDist.inv_cdfrcs	��fdd�td��D�S)Ncsg|]	}��|���qSr+)r�r��r3r�r+r,r�`sz(NormalDist.quantiles.<locals>.<listcomp>r-)r�)r�r3r+r�r,rWszNormalDist.quantilescCs 	t|t�s
td��||}}|j|jf|j|jfkr ||}}|j|j}}|r+|s/td��||}t|j|j�}|sLdt|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�)rjrrMr�r�rrrr!rr#r�)r��other�X�YZX_varZY_varZdvZdmrX�b�x1�x2r+r+r,�overlapbs$


(4zNormalDist.overlapcCs 	|jstd��||j|jS)Nz'zscore() not defined when sigma is zero)r�rr�r�r+r+r,�zscore�szNormalDist.zscorecC�	|jSr/�r��r�r+r+r,r	��zNormalDist.meancCr�r/r�r�r+r+r,r
�r�zNormalDist.mediancCr�r/r�r�r+r+r,r�szNormalDist.modecCr�r/�r�r�r+r+r,r�r�zNormalDist.stdevcCs	|jdS)Nr�r�r�r+r+r,r�s
zNormalDist.variancecCs:	t|t�rt|j|jt|j|j��St|j||j�Sr/�rjrr�rr��r�r�r+r+r,�__add__��
	zNormalDist.__add__cCs:	t|t�rt|j|jt|j|j��St|j||j�Sr/r�r�r+r+r,�__sub__�r�zNormalDist.__sub__cCs	t|j||jt|��Sr/�rr�r�rr�r+r+r,�__mul__��zNormalDist.__mul__cCs	t|j||jt|��Sr/r�r�r+r+r,�__truediv__�r�zNormalDist.__truediv__cCs	t|j|j�Sr/�rr�r��r�r+r+r,�__pos__�szNormalDist.__pos__cCs	t|j|j�Sr/r�r�r+r+r,�__neg__��zNormalDist.__neg__cCs	||Sr/r+r�r+r+r,�__rsub__�s
zNormalDist.__rsub__cCs(	t|t�stS|j|jko|j|jkSr/)rjr�NotImplementedr�r�r�r+r+r,�__eq__�s
zNormalDist.__eq__cCs	t|j|jf�Sr/)�hashr�r�r�r+r+r,�__hash__�r�zNormalDist.__hash__cCs t|�j�d|j�d|j�d�S)Nz(mu=z, sigma=�))r8r(r�r�r�r+r+r,�__repr__�s zNormalDist.__repr__cCs|j|jfSr/r�r�r+r+r,�__getstate__�szNormalDist.__getstate__cCs|\|_|_dSr/r�)r��stater+r+r,�__setstate__�szNormalDist.__setstate__)r�r�)r)"r(r)r*�	__slots__r��classmethodr�r�r�r�r�rr�r��propertyr	r
rrrr�r�r�r�r�r��__radd__r��__rmul__r�r�r�r�r�r+r+r+r,rsN�


"




r)r^r/)r-)=�__all__rGrkr�Z	fractionsr�decimalr�	itertoolsrrZbisectrrrrrr r!r"r#r$�operatorr%�collectionsr&r'rRrrErIr9r;rVrZr]r`r	rrrr
r
rrrrrr�rrrrrrr�rr�Z_statistics�ImportErrorrr+r+r+r,�<module>s`j(4


8
77
8

/
,

!-K�