Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
§ àÀ fYºãóv—UdZgd¢ZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z ddl mZmZddlmZmZmZmZmZmZmZmZdd lmZdd lmZdd lmZmZmZed ¦«Z Gd „de!¦«Z"d„Z#d?d„Z$d„Z%d„Z&d„Z'd„Z(d@d„Z)de*de*de*fd„Z+dej,j-zdzZ.e*e/d<de*de*de0fd„Z1de*de*de fd„Z2d „Z3d?d!„Z4d"„Z5d?d#„Z6d$„Z7d%„Z8d&„Z9dAd(„Z:d)„Z;d*„Zd?d0„Z?d?d1„Z@d?d2„ZAd3„ZBd4„ZCd5„ZDed6d7¦«ZEd8d9œd:„ZFd;„ZG dd¦«ZJdS)Ba× 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 Statistics for relations between two inputs ------------------------------------------- ================== ==================================================== Function Description ================== ==================================================== covariance Sample covariance for two variables. correlation Pearson's correlation coefficient for two variables. linear_regression Intercept and slope for simple linear regression. ================== ==================================================== Calculate covariance, Pearson's correlation, and simple linear regression for two inputs: >>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> y = [1, 2, 3, 1, 2, 3, 1, 2, 3] >>> covariance(x, y) 0.75 >>> correlation(x, y) #doctest: +ELLIPSIS 0.31622776601... >>> linear_regression(x, y) #doctest: LinearRegression(slope=0.1, intercept=1.5) Exceptions ---------- A single exception is defined: StatisticsError is a subclass of ValueError. )Ú 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)Úreduce)Úmul)ÚCounterÚ namedtupleÚ defaultdictç@có—eZdZdS)rN)Ú__name__Ú __module__Ú __qualname__©óú1/opt/alt/python311/lib64/python3.11/statistics.pyrr”s€€€€€Ø€Dr1rcóÄ—d}t¦«}|j}i}|j}t|t¦«D]B\}}||¦«t t |¦«D]\}} |dz }|| d¦«|z|| <ŒŒCd|vr|d} t| ¦«rJ‚n+td„|  ¦«D¦«¦«} tt|t¦«} | | |fS)a¨_sum(data) -> (type, sum, count) Return a high-precision sum of the given numeric data as a fraction, together with the type to be converted to and the count of items. Examples -------- >>> _sum([3, 2.25, 4.5, -0.5, 0.25]) (, Fraction(19, 2), 5) Some sources of round-off error will be avoided: # Built-in sum returns zero. >>> _sum([1e50, 1, -1e50] * 1000) (, Fraction(1000, 1), 3000) Fractions and Decimals are also supported: >>> from fractions import Fraction as F >>> _sum([F(2, 3), F(7, 5), F(1, 4), F(5, 6)]) (, Fraction(63, 20), 4) >>> from decimal import Decimal as D >>> data = [D("0.1375"), D("0.2108"), D("0.3061"), D("0.0419")] >>> _sum(data) (, Fraction(6963, 10000), 4) Mixed types are currently treated as an error, except that int is allowed. réNc3ó<K—|]\}}t||¦«V—ŒdS©Nr©Ú.0ÚdÚns r2ú z_sum..Ës.èè€Ð@Ð@¡t q¨!•H˜Q ‘N”NÐ@Ð@Ð@Ð@Ð@Ð@r1) ÚsetÚaddÚgetrÚtypeÚmapÚ _exact_ratioÚ _isfiniteÚsumÚitemsr&Ú_coerceÚint) ÚdataÚcountÚtypesÚ types_addÚpartialsÚ partials_getÚtypÚvaluesr:r9ÚtotalÚTs r2Ú_sumrQšs €ð@ €EÝ ‰EŒE€EØ” €IØ€HØ”<€Lݘt¥TÑ*Ô*ð1ð1‰ ˆˆV؈ �#‰ŒˆÝ�  fÑ-Ô-ð 1ð 1‰DˆAˆqØ �Q‰JˆEØ&˜, q¨!Ñ,Ô,¨qÑ0ˆH�Q‰KˆKð 1ð ˆxÐÐ𘔈ݘUÑ#Ô#Ð#Ð#Ð#Ð#õÐ@Ð@¨x¯~ª~Ñ/?Ô/?Ð@Ñ@Ô@Ñ@Ô@ˆÝ�w˜�sÑ#Ô#€AØ ˆu�eÐ Ðr1có"‡‡—‰�&tˆˆfd„|D¦«¦«\}}}||‰|fSd}t¦«}|j}tt¦«}tt¦«}t |t ¦«D]S\} } || ¦«tt| ¦«D]-\} Š|dz }|‰xx| z cc<|‰xx| | zz cc<Œ.ŒT|std¦«x}Šn‰d|vr|dx}Št|¦«rJ‚nitd„|  ¦«D¦«¦«} td„|  ¦«D¦«¦«} || z| | zz |z }| |z Štt|t¦«}||‰|fS)a3Return the exact mean and sum of square deviations of sequence data. Calculations are done in a single pass, allowing the input to be an iterator. If given *c* is used the mean; otherwise, it is calculated from the data. Use the *c* argument with care, as it can lead to garbage results. Nc3ó,•K—|]}|‰z xЉzV—ŒdSr6r0)r8ÚxÚcr9s €€r2r;z_ss..Ús0øèè€Ð<Ð<°! 1 q¡5˜j˜a¨AÑ-Ð<Ð<Ð<Ð<Ð<Ð.ïs.èè€Ð@Ð@¡D A q•˜!˜Q‘”Ð@Ð@Ð@Ð@Ð@Ð@r1c3óBK—|]\}}t|||z¦«V—ŒdSr6rr7s r2r;z_ss..ðs4èè€ÐDÐD¡t q¨!•(˜1˜a ™cÑ"Ô"ÐDÐDÐDÐDÐDÐDr1)rQr<r=r*rFrr?r@rArrBrCrDr&rE)rGrUrPÚssdrHrIrJÚ sx_partialsÚ sxx_partialsrMrNr:ÚsxÚsxxr9s ` @r2Ú_ssr]ÐsÚøø€ð €}ÝÐ<Ð<Ð<Ð<Ð<°tÐ<Ñ<Ô<Ñ<Ô<‰ ˆˆ3�Ø�3˜˜5Ð!Ð!Ø €EÝ ‰EŒE€EØ” €IÝ�cÑ"Ô"€KÝ�sÑ#Ô#€Lݘt¥TÑ*Ô*ð%ð%‰ ˆˆV؈ �#‰ŒˆÝ�  fÑ-Ô-ð %ð %‰DˆAˆqØ �Q‰JˆEØ ˜ˆNˆNŒN˜aÑ ˆNˆN‰NØ ˜ˆOˆOŒO˜q 1™uÑ $ˆOˆO‰OˆOð %ð ð ݘ1‘+”+ЈˆaˆaØ �Ð Ð ð˜dÔ#Ð#ˆˆaݘS‘>”>Ð!Ð!Ð!Ð!å Ð@Ð@¨K×,=Ò,=Ñ,?Ô,?Ð@Ñ@Ô@Ñ @Ô @ˆÝÐDÐD¨|×/AÒ/AÑ/CÔ/CÐDÑDÔDÑDÔDˆð�s‰{˜R "™WÑ$¨Ñ-ˆØ �‰JˆÝ�w˜�sÑ#Ô#€AØ ˆs�A�uÐ Ðr1cót— | ¦«S#t$rtj|¦«cYSwxYwr6)Ú is_finiteÚAttributeErrorÚmathÚisfinite)rTs r2rBrBùsF€ð Ø�{Š{‰}Œ}ÐøÝ ð ð ð ÝŒ}˜QÑÔÐÐÐð øøøs ‚–7¶7có—|tus Jd¦«‚||ur|S|tus |tur|S|tur|St||¦«r|St||¦«r|St|t¦«r|St|t¦«r|St|t¦«rt|t¦«r|St|t¦«rt|t¦«r|Sd}t ||j|jfz¦«‚)z½Coerce types T and S to a common type, or raise TypeError. Coercion rules are currently an implementation detail. See the CoerceTest test class in test_statistics for details. zinitial type T is boolz"don't know how to coerce %s and %s)ÚboolrFÚ issubclassrÚfloatÚ TypeErrorr-)rPÚSÚmsgs r2rErEs €ð •Dˆ=ˆ=ˆ=Ð2‰=Œ=ˆ=ð ˆA€v€v�q�à�C€x€x�1��9�9 a˜xØ�C€x€x˜�(å�!�QÑÔÐ" ˜(Ý�!�QÑÔÐ" ˜(å�!•SÑÔÐ$ 1˜HÝ�!•SÑÔÐ$ 1˜Hå�!•XÑÔð¥:¨aµÑ#7Ô#7ð؈Ý�!•UÑÔ𥠨1­hÑ 7Ô 7ð؈à .€CÝ �C˜1œ: q¤zÐ2Ñ2Ñ 3Ô 3Ð3r1có"— | ¦«S#t$rYn+ttf$rt |¦«rJ‚|dfcYSwxYw |j|jfS#t$r(dt|¦«j›d�}t|¦«‚wxYw)z¥Return Real number x to exact (numerator, denominator) pair. >>> _exact_ratio(0.25) (1, 4) x is expected to be an int, Fraction, Decimal or float. Nzcan't convert type 'z' to numerator/denominator) Úas_integer_ratior`Ú OverflowErrorÚ ValueErrorrBÚ numeratorÚ denominatorr?r-rg)rTris r2rArAsÆ€ð<Ø×!Ò!Ñ#Ô#Ð#øÝ ð ð ð Ø ˆÝ �:Ð &ðððå˜Q‘<”<ÐÐÐØ�4ˆyÐÐÐðøøøðà” ˜Qœ]Ð+Ð+øÝ ðððØQ¥T¨!¡W¤WÔ%5ÐQÐQÐQˆÝ˜‰nŒnÐðøøøs ‚– A ¢%A Á A Á AÁ2Bcó—t|¦«|ur|St|t¦«r|jdkrt} ||¦«S#t $r:t|t ¦«r#||j¦«||j¦«z cYS‚wxYw)z&Convert value to given numeric type T.r4)r?rerFrorfrgrrn)ÚvaluerPs r2Ú_convertrrMsª€å ˆE�{„{�aÐÐðˆ Ý�!•SÑÔð˜eÔ/°1Ò4Ð4Ý ˆðàˆq�‰xŒxˆøÝ ðððÝ �a�Ñ !Ô !ð Ø�1�U”_Ñ%Ô%¨¨¨%Ô*;Ñ(<Ô(<Ñ<Ð <Ð <Ð <à ð øøøs¼ AÁAB  B únegative valuec#óFK—|D]}|dkrt|¦«‚|V—ŒdS)z7Iterate over values, failing if any are less than zero.rN)r)rNÚerrmsgrTs r2Ú _fail_negrv_sAèè€à ððˆØ ˆqŠ5ˆ5Ý! &Ñ)Ô)Ð )؈ˆˆˆððr1r:ÚmÚreturncóN—tj||z¦«}|||z|z|kzS)zFSquare root of n/m, rounded to the nearest integer using round-to-odd.)raÚisqrt)r:rwÚas r2Ú_integer_sqrt_of_frac_rtor|gs.€õ Œ �1˜‘6ÑÔ€AØ ��!‘�A‘˜’ Ñ Ðr1ééÚ_sqrt_bit_widthcóð—| ¦«| ¦«z tz dz}|dkrt||d|zz¦«|z}d}nt|d|zz|¦«}d| z}||z S)z1Square root of n/m as a float, correctly rounded.r}rr4éþÿÿÿ)Ú bit_lengthrr|)r:rwÚqrnros r2Ú_float_sqrt_of_fracr„ss�€ð �ЉŒ˜!Ÿ,š,™.œ.Ñ (­?Ñ :¸qÑ@€A؈A‚v€vÝ-¨a°°a¸!±e±Ñ<Ô<ÀÑAˆ ؈ ˆ å-¨a°2¸±6©k¸1Ñ=Ô=ˆ ؘA˜2‘gˆ Ø �{Ñ "Ð"r1có—|dkr|std¦«S| | }}t|¦«t|¦«z  ¦«}| ¦«\}}| ¦«}| ¦«\}}d|z||zdzz|||z||zzdzzkr|S| ¦«}| ¦«\} } d|z|| zdzz||| z| |zzdzzkr|S|S)z3Square root of n/m as a Decimal, correctly rounded.rz0.0ér})rrrkÚ next_plusÚ next_minus) r:rwÚrootÚnrÚdrÚplusÚnpÚdpÚminusÚnmÚdms r2Ú_decimal_sqrt_of_fracr’€s €ð  ˆA‚v€vØð "ݘ5‘>”>Ð !؈r�A�2ˆ1ˆå �A‰JŒJ� ™œÑ #× )Ò )Ñ +Ô +€DØ × "Ò "Ñ $Ô $�F€Bˆà �>Š>Ñ Ô €DØ × "Ò "Ñ $Ô $�F€Bˆàˆ1�u��2‘˜‰zјA  B¡¨¨B©¡°Ñ 2Ñ2Ò2Ð2؈ à �OŠOÑ Ô €EØ × #Ò #Ñ %Ô %�F€Bˆàˆ1�u��2‘˜‰zјA  B¡¨¨B©¡°Ñ 2Ñ2Ò2Ð2؈ à €Kr1cóx—t|¦«\}}}|dkrtd¦«‚t||z |¦«S)aƒReturn the sample arithmetic mean of data. >>> mean([1, 2, 3, 4, 4]) 2.8 >>> from fractions import Fraction as F >>> mean([F(3, 7), F(1, 21), F(5, 3), F(1, 3)]) Fraction(13, 21) >>> from decimal import Decimal as D >>> mean([D("0.5"), D("0.75"), D("0.625"), D("0.375")]) Decimal('0.5625') If ``data`` is empty, StatisticsError will be raised. r4z%mean requires at least one data point)rQrrr)rGrPrOr:s r2r r žsA€õ �t‘*”*�K€A€uˆa؈1‚u€uÝÐEÑFÔFÐFÝ �E˜A‘I˜qÑ !Ô !Ð!r1cóð‡— t|¦«Šn"#t$rdŠˆfd„}||¦«}YnwxYw|€%t|¦«}‰std¦«‚|‰z S t|¦«}n.#t$r!t |¦«}t|¦«}YnwxYwtt t ||¦«¦«}‰|krtd¦«‚t|¦«}|std¦«‚||z S)zôConvert data to floats and compute the arithmetic mean. This runs faster than the mean() function and it always returns a float. If the input dataset is empty, it raises a StatisticsError. >>> fmean([3.5, 4.0, 5.25]) 4.25 rc3óB•K—t|d¬¦«D] \Š}|V—Œ dS)Nr4)Ústart)Ú enumerate)ÚiterablerTr:s €r2rHzfmean..countÂs<øèè€å! (°!Ð4Ñ4Ô4ð ð ‘��1Ø����ð ð r1Nz&fmean requires at least one data pointz(data and weights must be the same lengthzsum of weights must be non-zero)Úlenrgr%rÚlistr@r')rGÚweightsrHrOÚ num_weightsÚnumÚdenr:s @r2rr´s>ø€ð Ý �‰IŒIˆˆøÝ ðððà ˆð ð ð ð ð ðˆu�T‰{Œ{ˆˆˆðøøøð€Ý�T‘ ” ˆØð LÝ!Ð"JÑKÔKÐ KØ�q‰yÐð#ݘ'‘l”lˆ ˆ øÝ ð#ð#ð#Ý�w‘-”-ˆÝ˜'‘l”lˆ ˆ ˆ ð#øøøõ �s•3˜˜gÑ&Ô&Ñ 'Ô '€C؈KÒÐÝÐHÑIÔIÐIÝ ˆw‰-Œ-€CØ ðAÝÐ?Ñ@Ô@Ð@Ø �‰9Ðsƒ“2±2ÁA-Á-(BÂBcóž— tttt|¦«¦«¦«S#t$rt d¦«d‚wxYw)aYConvert data to floats and compute the geometric mean. Raises a StatisticsError if the input dataset is empty, if it contains a zero, or if it contains a negative value. No special efforts are made to achieve exact results. (However, this may change in the future.) >>> round(geometric_mean([54, 24, 36]), 9) 36.0 zGgeometric mean requires a non-empty dataset containing positive numbersN)r!rr@r$rmr)rGs r2rrÚs`€ðGÝ•5��S $™œÑ(Ô(Ñ)Ô)Ð)øÝ ðGðGðGÝð<ñ=ô=ØBFð GðGøøøs ‚.1±A có,—t|¦«|urt|¦«}d}t|¦«}|dkrtd¦«‚|dkrQ|€O|d}t |t jtf¦«r|dkrt|¦«‚|Std¦«‚|€td|¦«}|}nmt|¦«|urt|¦«}t|¦«|krtd¦«‚td„t||¦«D¦«¦«\}}} t||¦«}td „t||¦«D¦«¦«\}}} n#t$rYdSwxYw|dkrtd ¦«‚t||z |¦«S) aÞReturn the harmonic mean of data. The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals of the data. It can be used for averaging ratios or rates, for example speeds. Suppose a car travels 40 km/hr for 5 km and then speeds-up to 60 km/hr for another 5 km. What is the average speed? >>> harmonic_mean([40, 60]) 48.0 Suppose a car travels 40 km/hr for 5 km, and when traffic clears, speeds-up to 60 km/hr for the remaining 30 km of the journey. What is the average speed? >>> harmonic_mean([40, 60], weights=[5, 30]) 56.0 If ``data`` is empty, or any element is less than zero, ``harmonic_mean`` will raise ``StatisticsError``. z.harmonic mean does not support negative valuesr4z.harmonic_mean requires at least one data pointNrzunsupported typez*Number of weights does not match data sizec3óK—|]}|V—ŒdSr6r0)r8Úws r2r;z harmonic_mean..s"èè€Ð GÐ G q Ð GÐ GÐ GÐ GÐ GÐ Gr1c3ó.K—|]\}}|r||z ndV—ŒdS)rNr0)r8r¢rTs r2r;z harmonic_mean..s3èè€ÐPÐP±T°Q¸¨Ð0˜q 1™u˜u¨qÐPÐPÐPÐPÐPÐPr1zWeighted sum must be positive)Úiterršr™rÚ isinstanceÚnumbersÚRealrrgrrQrvÚzipÚZeroDivisionErrorrr) rGr›rur:rTÚ sum_weightsÚ_rPrOrHs r2rrísµ€õ. ˆD�z„z�TÐÐÝ�D‰zŒzˆØ =€FÝ ˆD‰ Œ €A؈1‚u€uÝÐNÑOÔOÐOØ ˆaŠˆ�G�OØ �ŒGˆÝ �a�'œ,­Ð0Ñ 1Ô 1ð 0Ø�1ŠuˆuÝ% fÑ-Ô-Ð-؈HåÐ.Ñ/Ô/Ð /؀ݘ˜A‘,”,ˆØˆ ˆ å �‰=Œ=˜GÐ #Ð #ݘ7‘m”mˆGÝ ˆw‰<Œ<˜1Ò Ð Ý!Ð"NÑOÔOÐ OÝ Ð GÐ G­I°g¸vÑ,FÔ,FÐ GÑ GÔ GÑGÔGшˆ;˜ðݘ˜vÑ&Ô&ˆÝÐPÐP½SÀÈ$Ñ=OÔ=OÐPÑPÔPÑPÔP‰ˆˆ5�%�%øÝ ððð؈qˆqðøøøà �‚z€zÝÐ=Ñ>Ô>Ð>Ý �K %Ñ'¨Ñ +Ô +Ð+sÄ!;EÅ E+Å*E+cóÈ—t|¦«}t|¦«}|dkrtd¦«‚|dzdkr ||dzS|dz}||dz ||zdz S)aBReturn the median (middle value) of numeric data. When the number of data points is odd, return the middle data point. When the number of data points is even, the median is interpolated by taking the average of the two middle values: >>> median([1, 3, 5]) 3 >>> median([1, 3, 5, 7]) 4.0 rúno median for empty datar}r4©Úsortedr™r)rGr:Úis r2r r %sr€õ �$‰<Œ<€DÝ ˆD‰ Œ €A؈A‚v€vÝÐ8Ñ9Ô9Ð9؈1�u�‚z€zØ�A˜‘FŒ|Ðà �‰FˆØ�Q˜‘U” ˜d 1œgÑ%¨Ñ*Ð*r1có¬—t|¦«}t|¦«}|dkrtd¦«‚|dzdkr ||dzS||dzdz S)a Return the low median of numeric data. When the number of data points is odd, the middle value is returned. When it is even, the smaller of the two middle values is returned. >>> median_low([1, 3, 5]) 3 >>> median_low([1, 3, 5, 7]) 3 rr­r}r4r®©rGr:s r2rr=s`€õ �$‰<Œ<€DÝ ˆD‰ Œ €A؈A‚v€vÝÐ8Ñ9Ô9Ð9؈1�u�‚z€zØ�A˜‘FŒ|Ðà�A˜‘F˜Q‘JÔÐr1có~—t|¦«}t|¦«}|dkrtd¦«‚||dzS)aReturn the high median of data. When the number of data points is odd, the middle value is returned. When it is even, the larger of the two middle values is returned. >>> median_high([1, 3, 5]) 3 >>> median_high([1, 3, 5, 7]) 5 rr­r}r®r²s r2r r Ss@€õ �$‰<Œ<€DÝ ˆD‰ Œ €A؈A‚v€vÝÐ8Ñ9Ô9Ð9Ø ��Q‘Œ<Ðr1çð?cót—t|¦«}t|¦«}|std¦«‚||dz}t||¦«}t |||¬¦«} t |¦«}t |¦«}n#t $rtd¦«‚wxYw||dz z }|}||z }|||dz |z z|z zS)a„Estimates the median for numeric data binned around the midpoints of consecutive, fixed-width intervals. The *data* can be any iterable of numeric data with each value being exactly the midpoint of a bin. At least one value must be present. The *interval* is width of each bin. For example, demographic information may have been summarized into consecutive ten-year age groups with each group being represented by the 5-year midpoints of the intervals: >>> demographics = Counter({ ... 25: 172, # 20 to 30 years old ... 35: 484, # 30 to 40 years old ... 45: 387, # 40 to 50 years old ... 55: 22, # 50 to 60 years old ... 65: 6, # 60 to 70 years old ... }) The 50th percentile (median) is the 536th person out of the 1071 member cohort. That person is in the 30 to 40 year old age group. The regular median() function would assume that everyone in the tricenarian age group was exactly 35 years old. A more tenable assumption is that the 484 members of that age group are evenly distributed between 30 and 40. For that, we use median_grouped(). >>> data = list(demographics.elements()) >>> median(data) 35 >>> round(median_grouped(data, interval=10), 1) 37.5 The caller is responsible for making sure the data points are separated by exact multiples of *interval*. This is essential for getting a correct result. The function does not check this precondition. Inputs may be any numeric type that can be coerced to a float during the interpolation step. r­r})Úloz$Value cannot be converted to a floatr+)r¯r™rrrrfrmrg) rGÚintervalr:rTr°ÚjÚLÚcfÚfs r2r r fsí€õV �$‰<Œ<€DÝ ˆD‰ Œ €AØ ð:ÝÐ8Ñ9Ô9Ð9ð ˆQ�!‰VŒ €Aõ �D˜!ÑÔ€AÝ�T˜1 Ð#Ñ#Ô#€AðAݘ‘?”?ˆÝ �!‰HŒHˆˆøÝ ðAðAðAÝÐ?Ñ@Ô@Ð@ðAøøøð ˆH�s‰NÑ€AØ €BØ ˆA‰€AØ ˆx˜1˜q™5 2™:Ñ&¨Ñ*Ñ *Ð*s ÁA=Á=Bcóº—tt|¦«¦« d¦«} |ddS#t$rt d¦«d‚wxYw)axReturn the most common data point from discrete or nominal data. ``mode`` assumes discrete data, and returns a single value. This is the standard treatment of the mode as commonly taught in schools: >>> mode([1, 1, 2, 3, 3, 3, 3, 4]) 3 This also works with nominal (non-numeric) data: >>> mode(["red", "blue", "blue", "red", "green", "red", "red"]) 'red' If there are multiple modes with same frequency, return the first one encountered: >>> mode(['red', 'red', 'green', 'blue', 'blue']) 'red' If *data* is empty, ``mode``, raises StatisticsError. r4rzno mode for empty dataN)r(r¤Ú most_commonÚ IndexErrorr)rGÚpairss r2rr®si€õ. •D˜‘J”JÑ Ô × +Ò +¨AÑ .Ô .€EðBØ�QŒx˜Œ{ÐøÝ ðBðBðBÝÐ6Ñ7Ô7¸TÐAðBøøøs ± ?¿AcóƇ—tt|¦«¦«}|sgSt| ¦«¦«Šˆfd„| ¦«D¦«S)a.Return a list of the most frequently occurring values. Will return more than one result if there are multiple modes or an empty list if *data* is empty. >>> multimode('aabbbbbbbbcc') ['b'] >>> multimode('aabbbbccddddeeffffgg') ['b', 'd', 'f'] >>> multimode('') [] có&•—g|] \}}|‰k¯ |‘ŒSr0r0)r8rqrHÚmaxcounts €r2ú zmultimode..Ýs'ø€Ð JÐ JÐ J‘l�e˜U¸ÀÒ8IÐ8IˆEÐ8IÐ8IÐ8Ir1)r(r¤ÚmaxrNrD)rGÚcountsrÂs @r2rrÌs\ø€õ•T˜$‘Z”ZÑ Ô €FØ ðØˆ Ý�6—=’=‘?”?Ñ#Ô#€HØ JÐ JÐ JÐ J f§l¢l¡n¤nÐ JÑ JÔ JÐJr1r†Ú exclusive)r:Úmethodcó”—|dkrtd¦«‚t|¦«}t|¦«}|dkrtd¦«‚|dkrg|dz }g}td|¦«D]M}t ||z|¦«\}}||||z z||dz|zz|z } | | ¦«ŒN|S|dkr||dz}g}td|¦«D]b}||z|z}|dkrdn||dz kr|dz n|}||z||zz }||dz ||z z|||zz|z } | | ¦«Œc|St d|›�¦«‚)a�Divide *data* into *n* continuous intervals with equal probability. Returns a list of (n - 1) cut points separating the intervals. Set *n* to 4 for quartiles (the default). Set *n* to 10 for deciles. Set *n* to 100 for percentiles which gives the 99 cuts points that separate *data* in to 100 equal sized groups. The *data* can be any iterable containing sample. The cut points are linearly interpolated between data points. If *method* is set to *inclusive*, *data* is treated as population data. The minimum value is treated as the 0th percentile and the maximum value is treated as the 100th percentile. r4zn must be at least 1r}z"must have at least two data pointsÚ inclusiverÆzUnknown method: )rr¯r™ÚrangeÚdivmodÚappendrm) rGr:rÇÚldrwÚresultr°r¸ÚdeltaÚ interpolateds r2rrs €ð  ˆ1‚u€uÝÐ4Ñ5Ô5Ð5Ý �$‰<Œ<€DÝ ˆT‰Œ€BØ ˆA‚v€vÝÐBÑCÔCÐCØ �ÒÐØ �‰FˆØˆÝ�q˜!‘”ð (ð (ˆAݘa !™e QÑ'Ô'‰HˆAˆuØ  œG q¨5¡yÑ1°D¸¸Q¹´KÀ%Ñ4GÑGÈ1ÑLˆLØ �MŠM˜,Ñ 'Ô 'Ð 'Ð '؈ Ø �ÒÐØ �‰FˆØˆÝ�q˜!‘”ð (ð (ˆAØ�A‘˜‘ ˆAؘ’U�U��¨¨B¨q©Dª¨  1¡ °aˆAØ�a‘C˜!˜A™#‘IˆEØ   Q¡œK¨1¨u©9Ñ5¸¸Q¼À%¹ÑGÈ1ÑLˆLØ �MŠM˜,Ñ 'Ô 'Ð 'Ð '؈ Ý Ð2¨Ð2Ð2Ñ 3Ô 3Ð3r1có‚—t||¦«\}}}}|dkrtd¦«‚t||dz z |¦«S)aÂReturn the sample variance of data. data should be an iterable of Real-valued numbers, with at least two values. The optional argument xbar, if given, should be the mean of the data. If it is missing or None, the mean is automatically calculated. Use this function when your data is a sample from a population. To calculate the variance from the entire population, see ``pvariance``. Examples: >>> data = [2.75, 1.75, 1.25, 0.25, 0.5, 1.25, 3.5] >>> variance(data) 1.3720238095238095 If you have already calculated the mean of your data, you can pass it as the optional second argument ``xbar`` to avoid recalculating it: >>> m = mean(data) >>> variance(data, m) 1.3720238095238095 This function does not check that ``xbar`` is actually the mean of ``data``. Giving arbitrary values for ``xbar`` may lead to invalid or impossible results. Decimals and Fractions are supported: >>> from decimal import Decimal as D >>> variance([D("27.5"), D("30.25"), D("30.25"), D("34.5"), D("41.75")]) Decimal('31.01875') >>> from fractions import Fraction as F >>> variance([F(1, 6), F(1, 2), F(5, 3)]) Fraction(67, 108) r}z*variance requires at least two data pointsr4©r]rrr)rGÚxbarrPÚssrUr:s r2rr6sJ€õL�d˜D‘/”/�K€A€rˆ1ˆa؈1‚u€uÝÐJÑKÔKÐKÝ �B˜!˜a™%‘L !Ñ $Ô $Ð$r1có|—t||¦«\}}}}|dkrtd¦«‚t||z |¦«S)a,Return the population variance of ``data``. data should be a sequence or iterable of Real-valued numbers, with at least one value. The optional argument mu, if given, should be the mean of the data. If it is missing or None, the mean is automatically calculated. Use this function to calculate the variance from the entire population. To estimate the variance from a sample, the ``variance`` function is usually a better choice. Examples: >>> data = [0.0, 0.25, 0.25, 1.25, 1.5, 1.75, 2.75, 3.25] >>> pvariance(data) 1.25 If you have already calculated the mean of the data, you can pass it as the optional second argument to avoid recalculating it: >>> mu = mean(data) >>> pvariance(data, mu) 1.25 Decimals and Fractions are supported: >>> from decimal import Decimal as D >>> pvariance([D("27.5"), D("30.25"), D("30.25"), D("34.5"), D("41.75")]) Decimal('24.815') >>> from fractions import Fraction as F >>> pvariance([F(1, 4), F(5, 4), F(1, 2)]) Fraction(13, 72) r4z*pvariance requires at least one data pointrÒ)rGÚmurPrÔrUr:s r2rrbsF€õF�d˜B‘-”-�K€A€rˆ1ˆa؈1‚u€uÝÐJÑKÔKÐKÝ �B˜‘F˜AÑ Ô Ðr1cóø—t||¦«\}}}}|dkrtd¦«‚||dz z }t|t¦«rt |j|j¦«St|j|j¦«S)z´Return the square root of the sample variance. See ``variance`` for arguments and other details. >>> stdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75]) 1.0810874155219827 r}ú'stdev requires at least two data pointsr4©r]rrerr’rnror„)rGrÓrPrÔrUr:Úmsss r2rr‹sy€õ�d˜D‘/”/�K€A€rˆ1ˆa؈1‚u€uÝÐGÑHÔHÐHØ ��A‘‰,€CÝ�!•WÑÔðEÝ$ S¤]°C´OÑDÔDÐDÝ ˜sœ}¨c¬oÑ >Ô >Ð>r1cóò—t||¦«\}}}}|dkrtd¦«‚||z }t|t¦«rt |j|j¦«St|j|j¦«S)z¹Return the square root of the population variance. See ``pvariance`` for arguments and other details. >>> pstdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75]) 0.986893273527251 r4z'pstdev requires at least one data pointrÙ)rGrÖrPrÔrUr:rÚs r2rr�su€õ�d˜B‘-”-�K€A€rˆ1ˆa؈1‚u€uÝÐGÑHÔHÐHØ ˆq‰&€CÝ�!•WÑÔðEÝ$ S¤]°C´OÑDÔDÐDÝ ˜sœ}¨c¬oÑ >Ô >Ð>r1có4—t|¦«\}}}}|dkrtd¦«‚||dz z } t|¦«t|j|j¦«fS#t $r1t|¦«t|¦«t|¦«z fcYSwxYw)zFIn one pass, compute the mean and sample standard deviation as floats.r}rØr4)r]rrfr„rnror`)rGrPrÔrÓr:rÚs r2Ú _mean_stdevrݯs¢€å˜‘Y”Y�N€A€rˆ4�؈1‚u€uÝÐGÑHÔHÐHØ ��A‘‰,€Cð4Ý�T‰{Œ{Õ/°´ ¸s¼ÑOÔOÐOÐOøÝ ð4ð4ð4å�T‰{Œ{�E $™KœK­%°©)¬)Ñ3Ð3Ð3Ð3Ð3ð4øøøs³(AÁ8BÂBcó>‡‡—t|¦«}t|¦«|krtd¦«‚|dkrtd¦«‚t|¦«|z Št|¦«|z Štˆˆfd„t||¦«D¦«¦«}||dz z S)apCovariance Return the sample covariance of two inputs *x* and *y*. Covariance is a measure of the joint variability of two inputs. >>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> y = [1, 2, 3, 1, 2, 3, 1, 2, 3] >>> covariance(x, y) 0.75 >>> z = [9, 8, 7, 6, 5, 4, 3, 2, 1] >>> covariance(x, z) -7.5 >>> covariance(z, x) -7.5 zDcovariance requires that both inputs have same number of data pointsr}z,covariance requires at least two data pointsc3ó4•K—|]\}}|‰z |‰z zV—ŒdSr6r0©r8ÚxiÚyirÓÚybars €€r2r;zcovariance..Ûó4øèè€ÐAÐA©V¨R°��T‘ ˜b 4™iÑ(ÐAÐAÐAÐAÐAÐAr1r4)r™rr%r¨)rTÚyr:ÚsxyrÓrãs @@r2rrÃs øø€õ" ˆA‰Œ€AÝ ˆ1�v„v�‚{€{ÝÐdÑeÔeÐe؈1‚u€uÝÐLÑMÔMÐMÝ �‰7Œ7�Q‰;€DÝ �‰7Œ7�Q‰;€DÝ ÐAÐAÐAÐAÐAµs¸1¸a±y´yÐAÑAÔAÑ AÔ A€CØ �!�a‘%‰=Ðr1c󇇇—t|¦«}t|¦«|krtd¦«‚|dkrtd¦«‚t|¦«|z Št|¦«|z Štˆˆfd„t||¦«D¦«¦«}tˆˆfd„|D¦«¦«}tˆˆfd„|D¦«¦«} |t ||z¦«z S#t $rtd¦«‚wxYw)aPearson's correlation coefficient Return the Pearson's correlation coefficient for two inputs. Pearson's correlation coefficient *r* takes values between -1 and +1. It measures the strength and direction of the linear relationship, where +1 means very strong, positive linear relationship, -1 very strong, negative linear relationship, and 0 no linear relationship. >>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> y = [9, 8, 7, 6, 5, 4, 3, 2, 1] >>> correlation(x, x) 1.0 >>> correlation(x, y) -1.0 zEcorrelation requires that both inputs have same number of data pointsr}z-correlation requires at least two data pointsc3ó4•K—|]\}}|‰z |‰z zV—ŒdSr6r0ràs €€r2r;zcorrelation..÷rär1c3ó,•K—|]}|‰z xЉzV—ŒdSr6r0©r8rár9rÓs €€r2r;zcorrelation..øó0øèè€Ð0Ð0¨�R˜$‘Y�� !Ñ#Ð0Ð0Ð0Ð0Ð0Ð0r1c3ó,•K—|]}|‰z xЉzV—ŒdSr6r0)r8râr9rãs €€r2r;zcorrelation..ùrër1z&at least one of the inputs is constant)r™rr%r¨rr©) rTrår:rær\Úsyyr9rÓrãs @@@r2rrßs&øøø€õ" ˆA‰Œ€AÝ ˆ1�v„v�‚{€{ÝÐeÑfÔfÐf؈1‚u€uÝÐMÑNÔNÐNÝ �‰7Œ7�Q‰;€DÝ �‰7Œ7�Q‰;€DÝ ÐAÐAÐAÐAÐAµs¸1¸a±y´yÐAÑAÔAÑ AÔ A€CÝ Ð0Ð0Ð0Ð0Ð0¨aÐ0Ñ0Ô0Ñ 0Ô 0€CÝ Ð0Ð0Ð0Ð0Ð0¨aÐ0Ñ0Ô0Ñ 0Ô 0€CðHØ•T˜# ™)‘_”_Ñ$Ð$øÝ ðHðHðHÝÐFÑGÔGÐGðHøøøs ÃC&Ã&DÚLinearRegression©ÚslopeÚ interceptF)Ú proportionalcóp‡‡ ‡ —t|¦«}t|¦«|krtd¦«‚|dkrtd¦«‚|rAtd„t||¦«D¦«¦«}td„|D¦«¦«}njt|¦«|z Š t|¦«|z Š tˆ ˆ fd„t||¦«D¦«¦«}tˆˆ fd„|D¦«¦«} ||z }n#t$rtd¦«‚wxYw|rd n‰ |‰ zz }t ||¬ ¦«S) aÉSlope and intercept for simple linear regression. Return the slope and intercept of simple linear regression parameters estimated using ordinary least squares. Simple linear regression describes relationship between an independent variable *x* and a dependent variable *y* in terms of a linear function: y = slope * x + intercept + noise where *slope* and *intercept* are the regression parameters that are estimated, and noise represents the variability of the data that was not explained by the linear regression (it is equal to the difference between predicted and actual values of the dependent variable). The parameters are returned as a named tuple. >>> x = [1, 2, 3, 4, 5] >>> noise = NormalDist().samples(5, seed=42) >>> y = [3 * x[i] + 2 + noise[i] for i in range(5)] >>> linear_regression(x, y) #doctest: +ELLIPSIS LinearRegression(slope=3.09078914170..., intercept=1.75684970486...) If *proportional* is true, the independent variable *x* and the dependent variable *y* are assumed to be directly proportional. The data is fit to a line passing through the origin. Since the *intercept* will always be 0.0, the underlying linear function simplifies to: y = slope * x + noise >>> y = [3 * x[i] + noise[i] for i in range(5)] >>> linear_regression(x, y, proportional=True) #doctest: +ELLIPSIS LinearRegression(slope=3.02447542484..., intercept=0.0) zKlinear regression requires that both inputs have same number of data pointsr}z3linear regression requires at least two data pointsc3ó&K—|] \}}||zV—Œ dSr6r0)r8rárâs r2r;z$linear_regression../s*èè€Ð3Ð3™v˜r 2�2˜‘7Ð3Ð3Ð3Ð3Ð3Ð3r1c3ó K—|] }||zV—Œ dSr6r0)r8rás r2r;z$linear_regression..0s&èè€Ð'Ð'˜r�2˜‘7Ð'Ð'Ð'Ð'Ð'Ð'r1c3ó4•K—|]\}}|‰z |‰z zV—ŒdSr6r0ràs €€r2r;z$linear_regression..4s4øèè€ÐEÐE±°°R�B˜‘I " t¡)Ñ,ÐEÐEÐEÐEÐEÐEr1c3ó,•K—|]}|‰z xЉzV—ŒdSr6r0rês €€r2r;z$linear_regression..5s0øèè€Ð4Ð4¨B˜˜d™�N�A aÑ'Ð4Ð4Ð4Ð4Ð4Ð4r1z x is constantçrï)r™rr%r¨r©rî) rTråròr:rær\rðrñr9rÓrãs @@@r2r r sføøø€õL ˆA‰Œ€AÝ ˆ1�v„v�‚{€{ÝÐkÑlÔlÐl؈1‚u€uÝÐSÑTÔTÐTØð5ÝÐ3Ð3­¨Q°©¬Ð3Ñ3Ô3Ñ3Ô3ˆÝÐ'Ð' QÐ'Ñ'Ô'Ñ'Ô'ˆˆå�A‰wŒw˜‰{ˆÝ�A‰wŒw˜‰{ˆÝÐEÐEÐEÐEÐE½3¸qÀ!¹9¼9ÐEÑEÔEÑEÔEˆÝÐ4Ð4Ð4Ð4Ð4°!Ð4Ñ4Ô4Ñ4Ô4ˆð/Ø�c‘ ˆˆøÝ ð/ð/ð/ݘoÑ.Ô.Ð.ð/øøøà#Ð<��¨°¸± Ñ)<€IÝ  %°9Ð =Ñ =Ô =Ð=s Ã8C>Ã>Dcó—|dz }t|¦«dkrpd||zz }d|zdz|zdz|zdz|zdz|zd z|zd z|zd z|z}d |zd z|zdz|zdz|zdz|zdz|zdz|zdz}||z }|||zzS|dkr|nd|z }tt|¦« ¦«}|dkr^|dz }d|zdz|zdz|zdz|zdz|zdz|zdz|zdz}d|zd z|zd!z|zd"z|zd#z|zd$z|zd%z|zdz}n]|dz }d&|zd'z|zd(z|zd)z|zd*z|zd+z|zd,z|zd-z}d.|zd/z|zd0z|zd1z|zd2z|zd3z|zd4z|zdz}||z }|dkr| }|||zzS)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@r´rø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¿tcI,\ó>g×Å�—¼ÈI?g*F2ùvŽ?gûC4ë†Á?g×ÇOÓ1ã?)r rr$)ÚprÖÚsigmarƒÚrr�ržrTs r2Ú_normal_dist_inv_cdfrþAs߀ð ˆC‰€AÝ ˆA�w„w�%ÒÐØ �q˜1‘uÑ ˆà0°1Ñ4Ø0ñ1Ø45ñ6à0ñ1à45ñ6ð1ñ1ð56ñ6ð1ñ 1ð56ñ 6ð 1ñ 1ð 56ñ 6ð 1ñ 1ð 56ñ 6ð1ñ1ð56ñ6ˆð1°1Ñ4Ø0ñ1Ø45ñ6à0ñ1à45ñ6ð1ñ1ð56ñ6ð1ñ 1ð56ñ 6ð 1ñ 1ð 56ñ 6ð 1ñ 1ð 56ñ 6ðñˆð �#‰IˆØ�Q˜‘YÑÐØ �#ŠXˆXˆˆ˜3 ™7€AÝ �c�!‰fŒfˆW‰ Œ €A؈C‚x€xØ �‰Gˆà1°AÑ5Ø1ñ2Ø56ñ7à1ñ2à56ñ7ð2ñ2ð67ñ7ð2ñ 2ð67ñ 7ð 2ñ 2ð 67ñ 7ð 2ñ 2ð 67ñ 7ð2ñ2ˆð2°AÑ5Ø1ñ2Ø56ñ7à1ñ2à56ñ7ð2ñ2ð67ñ7ð2ñ 2ð67ñ 7ð 2ñ 2ð 67ñ 7ð 2ñ 2ð 67ñ 7ðñˆˆð �‰Gˆà1°AÑ5Ø1ñ2Ø56ñ7à1ñ2à56ñ7ð2ñ2ð67ñ7ð2ñ 2ð67ñ 7ð 2ñ 2ð 67ñ 7ð 2ñ 2ð 67ñ 7ð2ñ2ˆð3°QÑ6Ø1ñ2Ø56ñ7à1ñ2à56ñ7ð2ñ2ð67ñ7ð2ñ 2ð67ñ 7ð 2ñ 2ð 67ñ 7ð 2ñ 2ð 67ñ 7ðñˆð ˆc‰ €A؈3‚w€wØ ˆBˆØ ��U‘Ñ Ðr1)rþcó*—eZdZdZdddœZd$d„Zed„¦«Zd d œd „Zd „Z d „Z d„Z d%d„Z d„Z d„Zed„¦«Zed„¦«Zed„¦«Zed„¦«Zed„¦«Zd„Zd„Zd„Zd„Zd„Zd„ZeZd„ZeZd„Zd „Zd!„Z d"„Z!d#„Z"d S)&rz(Normal distribution of a random variablez(Arithmetic mean of a normal distributionz+Standard deviation of a normal distribution©Ú_muÚ_sigmarør´có€—|dkrtd¦«‚t|¦«|_t|¦«|_dS)zDNormalDist where mu is the mean and sigma is the standard deviation.røzsigma must be non-negativeN)rrfrr)ÚselfrÖrüs r2Ú__init__zNormalDist.__init__œs8€à �3Š;ˆ;Ý!Ð">Ñ?Ô?Ð ?ݘ‘9”9ˆŒÝ˜E‘l”lˆŒ ˆ ˆ r1có&—|t|¦«ŽS)z5Make a normal distribution instance from sample data.)rÝ)ÚclsrGs r2Ú from_sampleszNormalDist.from_samples£s€ðˆs•K Ñ%Ô%Ð&Ð&r1N)Úseedc󮇇‡—|€ tjntj|¦«jŠ|j|jcŠŠˆˆˆfd„t |¦«D¦«S)z=Generate *n* samples for a given mean and standard deviation.Ncó(•—g|]}‰‰‰¦«‘ŒSr0r0)r8r°ÚgaussrÖrüs €€€r2rÃz&NormalDist.samples..¬s%ø€Ð3Ð3Ð3 Q���b˜%Ñ Ô Ð3Ð3Ð3r1)Úrandomr ÚRandomrrrÊ)rr:r r rÖrüs @@@r2ÚsampleszNormalDist.samples¨sVøøø€à $  •” � µ&´-ÀÑ2EÔ2EÔ2KˆØ”H˜dœkˆ ˆˆEØ3Ð3Ð3Ð3Ð3Ð3­%°©(¬(Ð3Ñ3Ô3Ð3r1có¶—|j|jz}|std¦«‚||jz }t||zd|zz ¦«t t |z¦«z S)z4Probability density function. P(x <= X < x+dx) / dxz$pdf() not defined when sigma is zerogÀ)rrrr!rr#)rrTrÚdiffs r2ÚpdfzNormalDist.pdf®s_€à”; ¤Ñ,ˆØð JÝ!Ð"HÑIÔIÐ IØ�4”8‰|ˆÝ�4˜$‘; $¨¡/Ñ2Ñ3Ô3µd½3À¹>Ñ6JÔ6JÑJÐJr1cóˆ—|jstd¦«‚ddt||jz |jtzz ¦«zzS)z,Cumulative distribution function. P(X <= x)z$cdf() not defined when sigma is zerorúr´)rrr"rÚ_SQRT2©rrTs r2ÚcdfzNormalDist.cdf¶sF€àŒ{ð JÝ!Ð"HÑIÔIÐ IØ�c�C  T¤X¡°$´+ÅÑ2FÑ GÑHÔHÑHÑIÐIr1có¢—|dks|dkrtd¦«‚|jdkrtd¦«‚t||j|j¦«S)aSInverse cumulative distribution function. x : P(X <= x) = p Finds the value of the random variable such that the probability of the variable being less than or equal to that value equals the given probability. This function is also called the percent point function or quantile function. rør´z$p must be in the range 0.0 < p < 1.0z-cdf() not defined when sigma at or below zero)rrrþr)rrûs r2Úinv_cdfzNormalDist.inv_cdf¼sV€ð �Š8ˆ8�q˜C’x�xÝ!Ð"HÑIÔIÐ IØ Œ;˜#Ò Ð Ý!Ð"QÑRÔRÐ RÝ# A t¤x°´Ñ=Ô=Ð=r1r†có@‡‡—ˆˆfd„td‰¦«D¦«S)anDivide into *n* continuous intervals with equal probability. Returns a list of (n - 1) cut points separating the intervals. Set *n* to 4 for quartiles (the default). Set *n* to 10 for deciles. Set *n* to 100 for percentiles which gives the 99 cuts points that separate the normal distribution in to 100 equal sized groups. có@•—g|]}‰ |‰z ¦«‘ŒSr0)r)r8r°r:rs €€r2rÃz(NormalDist.quantiles..Õs)ø€Ð9Ð9Ð9¨�— ’ ˜Q ™UÑ#Ô#Ð9Ð9Ð9r1r4)rÊ)rr:s``r2rzNormalDist.quantilesÌs+øø€ð:Ð9Ð9Ð9Ð9­U°1°a©[¬[Ð9Ñ9Ô9Ð9r1c ó —t|t¦«std¦«‚||}}|j|jf|j|jfkr||}}|j|j}}|r|st d¦«‚||z }t|j|jz ¦«}|s%dt|d|jztzz ¦«z S|j|z|j|zz }|j|jzt||z|t||z ¦«zz¦«z} || z|z } || z |z } dt|  | ¦«|  | ¦«z ¦«t|  | ¦«|  | ¦«z ¦«zz S)aºCompute the overlapping coefficient (OVL) between two normal distributions. Measures the agreement between two normal probability distributions. Returns a value between 0.0 and 1.0 giving the overlapping area in the two underlying probability density functions. >>> N1 = NormalDist(2.4, 1.6) >>> N2 = NormalDist(3.2, 2.0) >>> N1.overlap(N2) 0.8035050657330205 z$Expected another NormalDist instancez(overlap() not defined when sigma is zeror´r+) r¥rrgrrrrr r"rrr$r) rÚotherÚXÚYÚX_varÚY_varÚdvr‘r{ÚbÚx1Úx2s r2ÚoverlapzNormalDist.overlap×s‚€õ ˜%¥Ñ,Ô,ð DÝÐBÑCÔCÐ CØ�Uˆ1ˆØ ŒH�a”eÐ  ¤¨!¬%Ð0Ò 0Ð 0Ø�aˆqˆAØ”z 1¤:ˆuˆØð N˜Eð NÝ!Ð"LÑMÔMÐ MØ �U‰]ˆÝ �!”%˜!œ%‘-Ñ Ô ˆØð =Ø�˜R 3¨¬¡>µFÑ#:Ñ;Ñ<Ô<Ñ<Ð <Ø ŒE�E‰M˜AœE E™MÑ )ˆØ ŒH�q”xÑ ¥$ r¨B¡w°µc¸%À%¹-Ñ6HÔ6HÑ1HÑ'HÑ"IÔ"IÑ IˆØ�!‰e�r‰\ˆØ�!‰e�r‰\ˆØ•d˜1Ÿ5š5 ™9œ9 q§u¢u¨R¡y¤yÑ0Ñ1Ô1µD¸¿º¸r¹¼ÀQÇUÂUÈ2ÁYÄYÑ9NÑ4OÔ4OÑOÑPÐPr1cóR—|jstd¦«‚||jz |jz S)z¹Compute the Standard Score. (x - mean) / stdev Describes *x* in terms of the number of standard deviations above or below the mean of the normal distribution. z'zscore() not defined when sigma is zero)rrrrs r2ÚzscorezNormalDist.zscoreùs1€ðŒ{ð MÝ!Ð"KÑLÔLÐ LØ�D”H‘  ¤ Ñ+Ð+r1có—|jS)z+Arithmetic mean of the normal distribution.©r©rs r2r zNormalDist.meanó €ðŒxˆr1có—|jS)z,Return the median of the normal distributionr)r*s r2r zNormalDist.median r+r1có—|jS)z¨Return the mode of the normal distribution The mode is the value x where which the probability density function (pdf) takes its maximum value. r)r*s r2rzNormalDist.modes €ðŒxˆr1có—|jS)z.Standard deviation of the normal distribution.©rr*s r2rzNormalDist.stdevs €ðŒ{Ðr1có —|j|jzS)z!Square of the standard deviation.r/r*s r2rzNormalDist.variances€ðŒ{˜Tœ[Ñ(Ð(r1cóЗt|t¦«r5t|j|jzt|j|j¦«¦«St|j|z|j¦«S)ajAdd a constant or another NormalDist instance. If *other* is a constant, translate mu by the constant, leaving sigma unchanged. If *other* is a NormalDist, add both the means and the variances. Mathematically, this works only if the two distributions are independent or if they are jointly normally distributed. ©r¥rrrr©r#r$s r2Ú__add__zNormalDist.__add__!óU€õ �b�*Ñ %Ô %ð Lݘbœf r¤v™o­u°R´YÀÄ Ñ/JÔ/JÑKÔKÐ Kݘ"œ& 2™+ r¤yÑ1Ô1Ð1r1cóЗt|t¦«r5t|j|jz t|j|j¦«¦«St|j|z |j¦«S)asSubtract a constant or another NormalDist instance. If *other* is a constant, translate by the constant mu, leaving sigma unchanged. If *other* is a NormalDist, subtract the means and add the variances. Mathematically, this works only if the two distributions are independent or if they are jointly normally distributed. r2r3s r2Ú__sub__zNormalDist.__sub__/r5r1có\—t|j|z|jt|¦«z¦«S)zµMultiply both mu and sigma by a constant. Used for rescaling, perhaps to change measurement units. Sigma is scaled with the absolute value of the constant. ©rrrr r3s r2Ú__mul__zNormalDist.__mul__=ó'€õ ˜"œ& 2™+ r¤yµ4¸±8´8Ñ';Ñ<Ô<Ðð>ð>ð :ð :ð :ð :ð Qð Qð QðD ,ð ,ð ,ðððñ„Xððððñ„Xððððñ„Xððððñ„Xððð)ð)ñ„Xð)ð 2ð 2ð 2ð 2ð 2ð 2ð=ð=ð=ð=ð=ð=ð-ð-ð-ð.ð.ð.ð€Hðððð€Hð;ð;ð;ð -ð-ð-ðPðPðPð%ð%ð%ð&ð&ð&ð&ð&r1rr6)rs)r´)KrTÚ__all__rar¦r ÚsysÚ fractionsrÚdecimalrÚ itertoolsrrÚbisectrrrrr r!r"r#r$r%Ú functoolsr&Úoperatorr'Ú collectionsr(r)r*rrmrrQr]rBrErArrrvrFr|Ú float_infoÚmant_digrÚ__annotations__rfr„r’r rrrr rr r rrrrrrrrÝrrrîr rþÚ _statisticsÚ ImportErrorrr0r1r2úrhs‚ððhðhðhðT ð ð €ð. € € € Ø€€€Ø € € € Ø € € € àÐÐÐÐÐØÐÐÐÐÐØ%Ð%Ð%Ð%Ð%Ð%Ð%Ð%Ø,Ð,Ð,Ð,Ð,Ð,Ð,Ð,Ø<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<Ð<ØÐÐÐÐÐØÐÐÐÐÐØ8Ð8Ð8Ð8Ð8Ð8Ð8Ð8Ð8Ð8à ˆˆc‰Œ€ð ð ð ð ð �jñ ô ð ð 3ð3ð3ðl&ð&ð&ð&ðR ð ð ð4ð4ð4ð>+ð+ð+ð\ððð$ðððð ð¨ð°ððððð˜3œ>Ô2Ñ2°QÑ6€�Ð6Ð6Ñ6ð #˜3ð # 3ð #¨5ð #ð #ð #ð #ð˜Sð Sð¨Wððððð<"ð"ð"ð,#ð#ð#ð#ðLGðGðGð&5,ð5,ð5,ð5,ðp+ð+ð+ð0 ð ð ð,ððð&E+ðE+ðE+ðE+ðPBðBðBð<KðKðKðr ;ð(4ð(4ð(4ð(4ð(4ðb)%ð)%ð)%ð)%ðX&ð&ð&ð&ðR?ð?ð?ð?ð$?ð?ð?ð?ð$ 4ð 4ð 4ð(ððð8HðHðHðB�:Ð0Ð2HÑIÔIÐð05ð8>ð8>ð8>ð8>ð8>ð|GðGðGðV Ø0Ð0Ð0Ð0Ð0Ð0Ð0øØð ð ð Ø€Dð øøøð\&ð\&ð\&ð\&ð\&ñ\&ô\&ð\&ð\&ð\&sÄD!Ä!D)Ä(D)