shell bypass 403

GrazzMean-Shell Shell

Uname: Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.213.251.212
Your Ip: 3.17.128.87
User: allssztx (535) | Group: allssztx (533)
Safe Mode: OFF
Disable Function:
NONE

name : statistics.cpython-313.pyc
�

*}g���
���%Sr/SQrSSKrSSKrSSKrSSKrSSKJr SSKJ	r	 SSK
JrJrJ
r
 SSKJrJr SSKJrJrJrJrJrJrJrJrJr SS	KJrJrJrJrJrJrJ r J!r!J"r"J#r# SS
K$J%r% SSK&J'r' SSK(J)r)J*r*J+r+ \"S
5r,\r-"SS\.5r/Sr0SbSjr1Sr2Sr3Sr4Sr5ScSjr6SSSSS.S\7\84Sjjr9S\:S\:S\:4Sjr;S \RxRz-S!-r>\:\?S"'S\:S\:S\84S#jr@S\:S\:S\	4S$jrAS%rBSbS&jrCS'rDSbS(jrES)rFS*rGS+rHSdS,jrIS-rJS.rKSeSS0.S1jjrLS2S3S4.S5jrMSbS6jrNSbS7jrOSbS8jrPSbS9jrQS:rRS;\8S<\8S\84S=jrSS>rTS?S@.SAjrU\*"SBSC5rVSSD.SEjrWSFrXSSGKYJXrX "SHSI5r[SfSJjr\SKr]\\"\]SLSMSN9r^SOr_\\"\_SPSQSN9r`\["5R�SRSSSTSU\^\`SVSWSX.	rb\bS/\bSY'\bSZ\bS['\bS\\bS]'\bS^\bS_'SeSS`.Sajjrcg!\Za N|f=f)ga�

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�kde�
kde_random�linear_regression�mean�median�median_grouped�median_high�
median_low�mode�	multimode�pstdev�	pvariance�	quantiles�stdev�variance�N��Fraction)�Decimal)�count�groupby�repeat)�bisect_left�bisect_right)	�hypot�sqrt�fabs�exp�erf�tau�log�fsum�sumprod)
�isfinite�isinf�pi�cos�sin�tan�cosh�asin�atan�acos)�reduce)�
itemgetter)�Counter�
namedtuple�defaultdict�@c��\rSrSrSrg)r��N)�__name__�
__module__�__qualname__�__firstlineno__�__static_attributes__r<��1/opt/alt/python313/lib64/python3.13/statistics.pyrr�s��rBrc��Sn[5nURn0nURn[U[5H9upgU"U5 [[U5Hup�US-
nU"U	S5U-XI'M M; SU;aUSn
[U
5(aeO [SUR555n
[[U[5nX�U4$)aT_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])
(<class 'float'>, Fraction(19, 2), 5)

Some sources of round-off error will be avoided:

# Built-in sum returns zero.
>>> _sum([1e50, 1, -1e50] * 1000)
(<class 'float'>, 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)])
(<class 'fractions.Fraction'>, 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)
(<class 'decimal.Decimal'>, Fraction(6963, 10000), 4)

Mixed types are currently treated as an error, except that int is
allowed.
r�Nc3�<# �UHup[X!5v� M g7f�Nr��.0�d�ns   rC�	<genexpr>�_sum.<locals>.<genexpr>�s���@�/?�t�q�H�Q�N�N�/?���)
�set�add�getr�type�map�_exact_ratio�	_isfinite�sum�itemsr4�_coerce�int)�datar�types�	types_add�partials�partials_get�typ�valuesrKrJ�total�Ts            rC�_sumrc�s���@
�E��E�E��	�	�I��H��<�<�L��t�T�*����#����f�-�D�A��Q�J�E�&�q�!�,�q�0�H�K�.�+�
�x�������U�#�#�#�#�#��@�x�~�~�/?�@�@���w��s�#�A�
�e��rBc�^^�Tb[UU4SjU55up#nX#TU4$Sn[5nURn[[5n[[5n[U[5HHup�U"U	5 [[U
5H'unmUS-
nUT==U-
ss'UT==X�--
ss'M) MJ U(d[S5=nmOpSU;aUS=nm[U5(aeOP[SUR555n[SUR555n
XM-X�--
U-nX�-m[[U[5nX#TU4$)a#Return 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�6># �UHoT-
=mT-v� M g7frGr<)rI�x�crJs  ��rCrL�_ss.<locals>.<genexpr>�s����<�t�!�q�5�j�a�A�-�t�s�rrEc3�<# �UHup[X!5v� M g7frGrrHs   rCrLrh�s���@�,?�D�A��!���,?�rNc3�B# �UHup[X!U-5v� M g7frGrrHs   rCrLrh�s ���D�/C�t�q�(�1��c�"�"�/C�s�)rcrOrPr8rYrrRrSrTrrUrVrWr4rX)rZrgrb�ssdrr[r\�sx_partials�sxx_partialsr_r`rK�sx�sxxrJs `            @rC�_ssrp�sP���	�}��<�t�<�<�
�����5�!�!�
�E��E�E��	�	�I��c�"�K��s�#�L��t�T�*����#����f�-�D�A�q��Q�J�E���N�a��N���O�q�u�$�O�.�+���1�+���a�	
��	��d�#�#��a��S�>�>�!�!�>�
�@�K�,=�,=�,?�@�
@���D�|�/A�/A�/C�D�D���{�R�W�$��-���J���w��s�#�A�
�A�u��rBc�p�UR5$![a [R"U5s$f=frG)�	is_finite�AttributeError�mathr*)rfs rCrUrU�s1�� ��{�{�}���� ��}�}�Q��� �s�� 5�5c�
�U[LdS5eXLaU$U[Ld	U[LaU$U[LaU$[X5(aU$[X5(aU$[U[5(aU$[U[5(aU$[U[5(a[U[5(aU$[U[5(a[U[5(aU$Sn[X RUR4-5e)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)�boolrY�
issubclassr�float�	TypeErrorr=)rb�S�msgs   rCrXrXs���
�D�=�2�2�2�=�	�v�q���C�x�1��9�a�x��C�x��(��!����(��!����(��!�S���1�H��!�S���1�H��!�X���:�a��#7�#7����!�U���
�1�h� 7� 7���
.�C�
�C�:�:�q�z�z�2�2�
3�3rBc�(�UR5$![a O+[[4a [	U5(aeUS4s$f=fUR
UR4$![a% S[U5RS3n[U5ef=f)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_ratiors�
OverflowError�
ValueErrorrU�	numerator�denominatorrRr=ry)rfr{s  rCrTrT#s���<��!�!�#�#���
���:�&���Q�<�<����4�y��������Q�]�]�+�+����$�T�!�W�%5�%5�$6�6P�Q����n���s ��
A�%A�A�
A"�"/Bc� �[U5ULaU$[U[5(aURS:wa[nU"U5$![
a> [U[5(a'U"UR5U"UR5-s$ef=f)z&Convert value to given numeric type T.rE)rRrwrYr�rxryrr�)�valuerbs  rC�_convertr�Qs����E�{�a�����!�S���e�/�/�1�4������x������a��!�!��U�_�_�%��%�*;�*;�(<�<�<��	�s�A�AB
�B
c#�H# �UHnUS:a[U5eUv� M g7f)z7Iterate over values, failing if any are less than zero.rN)r)r`�errmsgrfs   rC�	_fail_negr�cs&���
���q�5�!�&�)�)����s� "F�averagerE)�key�reverse�ties�start�returnc�J�US:wa[SU<35eUb[X5n[[U[	55US9nUS-
nS/[U5-n[
U[S5S9H8up�[U	5n
[U
5nXkS-S--nU
H	up�X�U'M Xk-
nM: U$)a�Rank order a dataset. The lowest value has rank 1.

Ties are averaged so that equal values receive the same rank:

    >>> data = [31, 56, 31, 25, 75, 18]
    >>> _rank(data)
    [3.5, 5.0, 3.5, 2.0, 6.0, 1.0]

The operation is idempotent:

    >>> _rank([3.5, 5.0, 3.5, 2.0, 6.0, 1.0])
    [3.5, 5.0, 3.5, 2.0, 6.0, 1.0]

It is possible to rank the data in reverse order so that the
highest value has rank 1.  Also, a key-function can extract
the field to be ranked:

    >>> goals = [('eagles', 45), ('bears', 48), ('lions', 44)]
    >>> _rank(goals, key=itemgetter(1), reverse=True)
    [2.0, 1.0, 3.0]

Ranks are conventionally numbered starting from one; however,
setting *start* to zero allows the ranks to be used as array indices:

    >>> prize = ['Gold', 'Silver', 'Bronze', 'Certificate']
    >>> scores = [8.1, 7.3, 9.4, 8.3]
    >>> [prize[int(i)] for i in _rank(scores, start=0, reverse=True)]
    ['Bronze', 'Certificate', 'Gold', 'Silver']

r�zUnknown tie resolution method: )r�rEr)r��)	rrS�sorted�zipr�lenrr5�list)rZr�r�r�r��val_pos�i�result�_�g�group�size�rankr��orig_poss               rC�_rankr�ks���J�y���:�4�(�C�D�D�
���3�~���S��u�w�'��9�G�
��	�A��S�3�w�<�
�F���Z��]�3����Q����5�z���1�H��>�!��$�O�E�#�8�� %�	�	��
4��MrBrK�mc�L�[R"X-5nX"U-U-U:g-$)zFSquare root of n/m, rounded to the nearest integer using round-to-odd.)rt�isqrt)rKr��as   rC�_integer_sqrt_of_frac_rtor��s)��	
�
�
�1�6��A��!��A���
��rBr���_sqrt_bit_widthc���UR5UR5-
[-
S-nUS:�a[XSU--5U-nSnX4-$[USU--U5nSU*-nX4-$)z1Square root of n/m as a float, correctly rounded.r�rrE���)�
bit_lengthr�r�)rKr��qr�r�s     rC�_float_sqrt_of_fracr��s|��
����!�,�,�.�	(�?�	:�q�@�A��A�v�-�a�a�!�e��<��A�	����"�"�.�a�2��6�k�1�=�	��A�2�g���"�"rBc��US::aU(d[S5$U*U*p[U5[U5-R5nUR5up4UR5nUR5upgSU-XG-S--XU-Xs--S--:�aU$UR	5nUR5up�SU-XJ-S--XU	-X�--S--:aU$U$)z3Square root of n/m as a Decimal, correctly rounded.rz0.0�r�)rr"r}�	next_plus�
next_minus)rKr��root�nr�dr�plus�np�dp�minus�nm�dms           rC�_decimal_sqrt_of_fracr��s���
	�A�v���5�>�!��r�A�2�1��A�J����#�)�)�+�D�
�
"�
"�
$�F�B��>�>��D�
�
"�
"�
$�F�B��1�u����z��A�B������ 2�2�2����O�O��E�
�
#�
#�
%�F�B��1�u����z��A�B������ 2�2�2����KrBc�\�[U5upnUS:a[S5e[X#-U5$)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.
rEz%mean requires at least one data point)rcrr�)rZrbrarKs    rCrr�s3�� �t�*�K�A�a��1�u��E�F�F��E�I�q�!�!rBc�~^�Uc.[U5m[U5nT(d[S5eUT-$[	U[
[45(d[U5n[X5n[U5nU(d[S5eXE-$![a SmU4SjnU"U5nN�f=f![a [S5ef=f)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�>># �[USS9H
umnUv� M g7f)NrE�r�)�	enumerate)�iterablerfrKs  �rCr�fmean.<locals>.count�s ����%�h�a�8�D�A�q��G�9�s�z&fmean requires at least one data pointz(data and weights must be the same lengthzsum of weights must be non-zero)	r�ryr(r�
isinstancer��tupler)r)rZ�weightsrra�num�denrKs      @rCrr�s������		��D�	�A��T�
���!�"J�K�K��q�y���g��e�}�-�-��w�-��J��d�$���w�-�C���?�@�@��9���+�	��A�
���;�D�	�� �J��H�I�I�J�s�B�B&�B#�"B#�&B<c�J^^�SmSmUU4Sjn[[[U"U555nT(d[S5e[R
"U5(a[R$T(a&U[R:Xa[R$S$[UT-5$)aUConvert data to floats and compute the geometric mean.

Raises a StatisticsError if the input dataset is empty
or if it contains a negative value.

Returns zero if the product of inputs is zero.

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
rFc3�># �[USS9HAumnUS:�d[R"U5(aUv� M-US:XaSmM7[SU5e g7f)NrEr��TzNo negative inputs allowed)r�rt�isnanr)r�rf�
found_zerorKs  ��rC�count_positive�&geometric_mean.<locals>.count_positive"sM�����h�a�0�D�A�q��3�w�$�*�*�Q�-�-����c��!�
�%�&B�A�F�F�
1�s�AAzMust have a non-empty datasetr�)	r(rSr'rrtr��nan�infr$)rZr�rar�rKs   @@rCrrs���	
�A��J�G�
��S�.��.�/�0�E���=�>�>��z�z�%����x�x��� �D�H�H�,�t�x�x�5�#�5��u�q�y�>�rBc��[U5ULa[U5nSn[U5nUS:a[S5eUS:XaKUcHUSn[	U[
R[45(aUS:a[U5eU$[S5eUc[SU5nUnOQ[U5ULa[U5n[U5U:wa[S5e[S[X555upen[X5n[S[X555upxn	US::a[S	5e[XX-U5$![a gf=f)
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 valuesrEz.harmonic_mean requires at least one data pointrzunsupported typez*Number of weights does not match data sizec3�$# �UHov� M g7frGr<)rI�ws  rCrL� harmonic_mean.<locals>.<genexpr>bs��� G�,F�q��,F�s�c3�@# �UHupU(aX-OSv� M g7f)rNr<)rIr�rfs   rCrLr�es���P�=O�T�Q��q�u�q�0�=O�s�zWeighted sum must be positive)�iterr�r�rr��numbers�Realrryrrcr�r��ZeroDivisionErrorr�)
rZr�r�rKrf�sum_weightsr�rbrars
          rCrr5sD��.�D�z�T���D�z��
=�F��D�	�A��1�u��N�O�O�	
�a��G�O���G���a�'�,�,��0�1�1��1�u�%�f�-�-��H��.�/�/�����A�,������=�G�#��7�m�G��w�<�1��!�"N�O�O� � G�I�g�,F� G�G�������&���P�S��=O�P�P���%�
��z��=�>�>��K�'��+�+��	����s�-)D5�5
E�Ec��[U5n[U5nUS:Xa[S5eUS-S:XaXS-$US-nXS-
X-S-$)a"Return 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�rE�r�r�r)rZrKr�s   rCr
r
msa���$�<�D��D�	�A��A�v��8�9�9��1�u��z���F�|��
��F����U��d�g�%��*�*rBc��[U5n[U5nUS:Xa[S5eUS-S:XaXS-$XS-S-
$)z�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�rEr��rZrKs  rCrr�sQ���$�<�D��D�	�A��A�v��8�9�9��1�u��z���F�|����F�Q�J��rBc�^�[U5n[U5nUS:Xa[S5eXS-$)z�Return 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  rCrr�s5���$�<�D��D�	�A��A�v��8�9�9��Q��<�rBc�$�[U5n[U5nU(d[S5eXS-n[X5n[	XUS9n[U5n[U5nX1S--
nUnXT-
nXaUS-U-
-U--$![a [S5ef=f)aEstimates 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 floatr9)r�r�rrr rxrry)	rZ�intervalrKrfr��j�L�cf�fs	         rCrr�s���V�$�<�D��D�	�A���8�9�9�	
�!�V��A�	�D��A��T��#�A�A���?���!�H��	
�s�N��A�	
�B�	��A��1�q�5�2�:�&��*�*�*���A��>�@�@�A�s�A9�9Bc��[[U55RS5nUSS$![a
 [	S5Sef=f)aDReturn 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.

rErzno mode for empty dataN)r6r��most_common�
IndexErrorr)rZ�pairss  rCrr�sP��.
�D��J��+�+�A�.�E�B��Q�x��{����B��6�7�T�A�B�s	�-�Ac���[[U55nU(d/$[UR55nUR	5VVs/sHup4XB:XdMUPM snn$s snnf)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('')
[]
)r6r��maxr`rW)rZ�counts�maxcountr�rs     rCrrsO���T�$�Z�
 �F���	��6�=�=�?�#�H�&,�l�l�n�J�n�l�e��8I�E�n�J�J��Js�
A#�A#�normal)�
cumulativec��^^^^^	^
^^^
^^�[T5mT(d[S5e[TS[[45(d[S5eTS::a[ST<35eU==S:XaO	=S:XaO O.  [
S[-5m[
S5mU4S	jmU4S
jmSnO�=S:Xa
 S
mSmSnO�=S:Xa" S[-m
S[-mU
4SjmU4SjmSnO�==S:XaO	=S:XaO O  SmSmSnO�=S:Xa
 SmSmSnO==S:XaO	=S:XaO O  SmSmSnOc==S:XaO	=S :XaO O  S!mS"mSnOG=S#:Xa
 S$mS%mSnO7S&:Xa"[S'-m
[S-mU
U4S(jmU4S)jmSnO[S*U<35eUcUUU4S+jnUUU4S,jnO&[T5m
TU-m	UU	UUUU
4S-jnUU	UUUU
4S.jnU(aS/T<S0U<3Ul	U$S1T<S0U<3Ul	U$)2a�Kernel Density Estimation:  Create a continuous probability density
function or cumulative distribution function from discrete samples.

The basic idea is to smooth the data using a kernel function
to help draw inferences about a population from a sample.

The degree of smoothing is controlled by the scaling parameter h
which is called the bandwidth.  Smaller values emphasize local
features while larger values give smoother results.

The kernel determines the relative weights of the sample data
points.  Generally, the choice of kernel shape does not matter
as much as the more influential bandwidth smoothing parameter.

Kernels that give some weight to every sample point:

   normal (gauss)
   logistic
   sigmoid

Kernels that only give weight to sample points within
the bandwidth:

   rectangular (uniform)
   triangular
   parabolic (epanechnikov)
   quartic (biweight)
   triweight
   cosine

If *cumulative* is true, will return a cumulative distribution function.

A StatisticsError will be raised if the data sequence is empty.

Example
-------

Given a sample of six data points, construct a continuous
function that estimates the underlying probability density:

    >>> sample = [-2.1, -1.3, -0.4, 1.9, 5.1, 6.2]
    >>> f_hat = kde(sample, h=1.5)

Compute the area under the curve:

    >>> area = sum(f_hat(x) for x in range(-20, 20))
    >>> round(area, 4)
    1.0

Plot the estimated probability density function at
evenly spaced points from -6 to 10:

    >>> for x in range(-6, 11):
    ...     density = f_hat(x)
    ...     plot = ' ' * int(density * 400) + 'x'
    ...     print(f'{x:2}: {density:.3f} {plot}')
    ...
    -6: 0.002 x
    -5: 0.009    x
    -4: 0.031             x
    -3: 0.070                             x
    -2: 0.111                                             x
    -1: 0.125                                                   x
     0: 0.110                                            x
     1: 0.086                                   x
     2: 0.068                            x
     3: 0.059                        x
     4: 0.066                           x
     5: 0.082                                 x
     6: 0.082                                 x
     7: 0.058                        x
     8: 0.028            x
     9: 0.009    x
    10: 0.002 x

Estimate P(4.5 < X <= 7.5), the probability that a new sample value
will be between 4.5 and 7.5:

    >>> cdf = kde(sample, h=1.5, cumulative=True)
    >>> round(cdf(7.5) - cdf(4.5), 2)
    0.22

References
----------

Kernel density estimation and its application:
https://www.itm-conferences.org/articles/itmconf/pdf/2018/08/itmconf_sam2018_00037.pdf

Kernel functions in common use:
https://en.wikipedia.org/wiki/Kernel_(statistics)#kernel_functions_in_common_use

Interactive graphical demonstration and exploration:
https://demonstrations.wolfram.com/KernelDensityEstimation/

Kernel estimation of cumulative distribution function of a random variable with bounded support
https://www.econstor.eu/bitstream/10419/207829/1/10.21307_stattrans-2016-037.pdf

�Empty data sequencer�)Data sequence must contain ints or floatsr��$Bandwidth h must be positive, not h=r��gaussr�c�,>�[SU-U-5T-$)N�࿩r$)�t�sqrt2pis �rC�<lambda>�kde.<locals>.<lambda>�s���#�d�Q�h��l�+�g�5rBc�,>�SS[UT-5--$�N��?��?)r%)r��sqrt2s �rCr�r��s���#��s�1�u�9�~�!5�6rBN�logisticc�$�SS[U5--$r��r0�r�s rCr�r��s��#��t�A�w��/rBc�*�SS[U5S---
$�Nr�r�rs rCr�r��s��#��s�1�v��|� 4�4rB�sigmoidrEc� >�T[U5-$rGr)r��c1s �rCr�r��s
���"�t�A�w�,rBc�2>�T[[U55-$rG)r2r$�r��c2s �rCr�r��s���"�t�C��F�|�+rB�rectangular�uniformc��g�Nr�r<rs rCr�r��s��#rBc��SU-S-$rr<rs rCr�r��s��#��'�C�-rBr��
triangularc��S[U5-
$r��absrs rCr�r��s��#��A��,rBc�,�X-US:aSOS-U-S-$)Nr�r�r�r<rs rCr�r��s��!�#��C���T�:�Q�>��DrB�	parabolic�epanechnikovc��SSX--
-$)N��?r�r<rs rCr�r��s��#��q�u��-rBc�$�SUS--SU--S-$)Ngпr�rr�r<rs rCr�r��s��$��A��+��a��/�#�5rB�quartic�biweightc��SSX--
S--$�N��?r�r�r<rs rCr�r�����%�3���;�1�"4�4rBc�6�SUS--SUS---
SU--S-$�Ng�?�g�?r�rr�r<rs rCr�r��s'��$��A��+��a��d�
�2�U�Q�Y�>��DrB�	triweightc��SSX--
S--$�N���?r�r�r<rs rCr�r��rrBc�B�SSUS--SUS---US--
U--S-$�Nr&g�$I�$I¿�g333333�?r"r�r�r<rs rCr�r��s1��%�4��1��9�s�1�a�4�x�#7�!�Q�$�#>��#B�C�c�IrB�cosiner�c�&>�T[TU-5-$rG)r-)r�rr
s ��rCr�r��s���"�s�2��6�{�*rBc�,>�S[TU-5-S-$r�r.r	s �rCr�r��s���#��B��F��+�c�1rB�Unknown kernel name: c�V>^�[T5n[UUU4SjT55UT--$)Nc3�@># �UHnT"TU-
T-5v� M g7frGr<�rI�x_i�K�hrfs  ���rCrL�#kde.<locals>.pdf.<locals>.<genexpr>��!����8�4�C�q�!�c�'�Q��'�'�4����r�rV)rfrKr3rZr4s` ���rC�pdf�kde.<locals>.pdf�s&����D�	�A��8�4�8�8�A��E�B�BrBc�P>^�[T5n[UUU4SjT55U-$)Nc3�@># �UHnT"TU-
T-5v� M g7frGr<�rIr2�Wr4rfs  ���rCrL�#kde.<locals>.cdf.<locals>.<genexpr>�r6r7r8)rfrKr>rZr4s` ���rC�cdf�kde.<locals>.cdf�s"����D�	�A��8�4�8�8�1�<�<rBc��>^�[T5T:wa[T5m	[T5m[T	TT-
5n[T	TT-5nT	Xn[	UUU4SjU55TT--$)Nc3�@># �UHnT"TU-
T-5v� M g7frGr<r1s  ���rCrLr5�s!����=�9�C�q�!�c�'�Q��'�'�9�r7�r�r�rr rV)
rfr�r��	supportedr3�	bandwidthrZr4rK�samples
`   ������rCr9r:�sc����4�y�A�~�������I���F�A�	�M�2�A��V�Q��]�3�A��q�
�I��=�9�=�=��Q��G�GrBc��>^�[T5T:wa[T5m	[T5m[T	TT-
5n[T	TT-5nT	Xn[	UUU4SjU5U5T-$)Nc3�@># �UHnT"TU-
T-5v� M g7frGr<r=s  ���rCrLr?�s!����>�I�S��1�s�7�a�-�(�(�I�r7rD)
rfr�r�rEr>rFrZr4rKrGs
`   ������rCr@rA�sa����4�y�A�~�������I���F�A�	�M�2�A��V�Q��]�3�A��q�
�I��>�I�>��B�Q�F�FrBzCDF estimate with h=� and kernel=zPDF estimate with h=)
r�rr�rYrxryr"r,r��__doc__)rZr4�kernelr��supportr9r@r3r>rFrr
rKrGr�r�s``     @@@@@@@@@rCr	r	(s�����H	�D�	�A���3�4�4��d�1�g��U�|�,�,��C�D�D��C�x�� E�1�&�I�J�J�
�
�X��
��1�r�6�l�G���G�E�5�A�6�A��G�
�/�A�4�A��G�
��R��B��R��B�&�A�+�A��G�
&�]�Y�
&��A�'�A��G�
�&�A�D�A��G�
)�[�>�
)�-�A�5�A��G�
#�Y��
#�4�A�D�A��G�
�4�A�I�A��G�
��a��B��a��B�*�A�1�A��G�
�!�$9�&��"D�E�E���	C�	=�	=�������K�	�	H�	H�	G�	G��-�1�&�
�f�[�A����
�.�1�&�
�f�[�A����
rBr��	exclusive)rK�methodc�@�US:a[S5e[U5n[U5nUS:aUS:XaXS-
-$[S5eUS:XaTUS-
n/n[SU5H;n[	Xd-U5upxXX-
-XS-U--U-n	URU	5 M= U$US:XakUS-n/n[SU5HRnXd-U-nUS:aSOXsS-
:�aUS-
OUnXd-Xq--
nXS-
X-
-XU--U-n	URU	5 MT U$[
SU<35e)aeDivide *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.
rEzn must be at least 1r�z!must have at least one data point�	inclusiverN�Unknown method: )rr�r��range�divmod�appendr)
rZrKrO�ldr�r�r�r��delta�interpolateds
          rCrr!s\�� 	�1�u��4�5�5��$�<�D�	�T��B�	�A�v�
��7��q�5�>�!��A�B�B�
�����F�����q�!��A��a�e�Q�'�H�A� �G�q�y�1�D�Q��K�%�4G�G�1�L�L��M�M�,�'���
�
�����F�����q�!��A����
�A���U���q�D���1��a�A��C�!�#�I�E� �Q��K�1�9�5���%��G�1�L�L��M�M�,�'���
�
�'��z�2�
3�3rBc�b�[X5up#pEUS:a[S5e[X5S-
-U5$)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 pointsrE�rprr�)rZ�xbarrb�ssrgrKs      rCrrWs8��L�d�/�K�A�1��1�u��J�K�K��B�a�%�L�!�$�$rBc�\�[X5up#pEUS:a[S5e[X5-U5$)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)

rEz*pvariance requires at least one data pointrZ)rZ�murbr\rgrKs      rCrr�s4��F�d�-�K�A�1��1�u��J�K�K��B�F�A��rBc��[X5up#pEUS:a[S5eX5S-
-n[U[5(a [	UR
UR5$[UR
UR5$)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 pointsrE�rprrwrr�r�r�r�)rZr[rbr\rgrK�msss       rCrr�sf���d�/�K�A�1��1�u��G�H�H�
�A��,�C��!�W���$�S�]�]�C�O�O�D�D��s�}�}�c�o�o�>�>rBc���[X5up#pEUS:a[S5eX5-n[U[5(a [	UR
UR5$[UR
UR5$)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

rEz'pstdev requires at least one data pointra)rZr^rbr\rgrKrbs       rCrr�sb���d�-�K�A�1��1�u��G�H�H�
�&�C��!�W���$�S�]�]�C�O�O�D�D��s�}�}�c�o�o�>�>rBc�
�[U5upp4US:a[S5eX$S-
-n[U5[URUR
54$![a% [U5[U5[U5-4s$f=f)zFIn one pass, compute the mean and sample standard deviation as floats.r�r`rE)rprrxr�r�r�rs)rZrbr\r[rKrbs      rC�_mean_stdevre�s|����Y�N�A�4��1�u��G�H�H�
�A��,�C�4��T�{�/��
�
�s���O�O�O���4��T�{�E�$�K�%��)�3�3�3�4�s�*A�,B�Brf�yc�T�[X-5n[U5(dG[U5(a5[U5(d%[U5(dSn[X0-X1-5U-$U$U(d%U(aU(aSn[X0-X1-5U-$U$[	X4X*45nX$SU---$)zRReturn sqrt(x * y) computed with improved accuracy and without overflow/underflow.g�g�ar9)r"r*r+�	_sqrtprodr))rfrfr4�scalerJs     rCrhrh�s����Q�U��A��A�;�;���8�8�E�!�H�H�U�1�X�X��E��U�Y��	�2�U�:�:�������E��U�Y��	�2�U�:�:���	����B�� �A��C�!�G�}��rBc�^^�[U5n[U5U:wa[S5eUS:a[S5e[U5U-m[U5U-m[U4SjU5U4SjU55nX2S-
-$)a@Covariance

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�,># �UH	oT-
v� M g7frGr<)rI�xir[s  �rCrL�covariance.<locals>.<genexpr>s����)�q���9�q���c3�,># �UH	oT-
v� M g7frGr<�rI�yi�ybars  �rCrLrms����+B��"��I��rnrE)r�rr(r))rfrfrK�sxyr[rrs    @@rCrr�sv���"	�A��A�
�1�v��{��d�e�e��1�u��L�M�M���7�Q�;�D���7�Q�;�D�
�)�q�)�+B��+B�
C�C��a�%�=�rB�linear)rOc��[U5n[U5U:wa[S5eUS:a[S5eUS;a[SU<35eUS:XaUS-
S-n[XS	9n[XS	9nOD[	U5U-n[	U5U-nUVs/sHowU-
PM	 nnUVs/sHo�U-
PM	 nn[X5n	[X5n
[X5nU	[
X�5-$s snfs snf![a [S
5ef=f)a(Pearson'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 a 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

If *method* is "ranked", computes Spearman's rank correlation coefficient
for two inputs.  The data is replaced by ranks.  Ties are averaged
so that equal values receive the same rank.  The resulting coefficient
measures the strength of a monotonic relationship.

Spearman's rank correlation coefficient is appropriate for ordinal
data or for continuous data that doesn't meet the linear proportion
requirement for Pearson's correlation coefficient.
zEcorrelation requires that both inputs have same number of data pointsr�z-correlation requires at least two data points>rt�rankedrRrvrEr�r�z&at least one of the inputs is constant)r�rrr�r(r)rhr�)rfrfrOrKr�r[rrrlrqrsro�syys            rCrrs��.	�A��A�
�1�v��{��e�f�f��1�u��M�N�N�
�)�)��+�F�:�6�7�7�
����Q��"����!�!���!�!���A�w��{���A�w��{��!"�#��2�$�Y���#�!"�#��2�$�Y���#�
�!�-�C�
�!�-�C�
�!�-�C�H��Y�s�(�(�(��

$��#���H��F�G�G�H�s�
C!�!C&�
C+�+D�LinearRegression��slope�	intercept)�proportionalc�^
�[U5n[U5U:wa[S5eUS:a[S5eU(d<[U5U-n[U5U-m
UVs/sHoUU-
PM	 nnU
4SjU5n[X5S-n[X5nXg-nU(aSOT
UW--
n	[X�S9$s snf![a [S5ef=f)aOSlope 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.17495..., intercept=1.00925...)

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=2.90475..., intercept=0.0)

zKlinear regression requires that both inputs have same number of data pointsr�z3linear regression requires at least two data pointsc3�,># �UH	oT-
v� M g7frGr<rps  �rCrL�$linear_regression.<locals>.<genexpr>ws����#��2�$�Y��rnr�z
x is constantry)r�rr(r)r�rx)rfrfr|rKr[rlrsrorzr{rrs          @rCrrHs����L	�A��A�
�1�v��{��k�l�l��1�u��S�T�T���A�w��{���A�w��{��!"�#��2�$�Y���#�#��#��
�!�-�#�
�C�
�!�-�C�/��	��$������)<�I��%�=�=��
$���/��o�.�.�/�s�B3�B8�8Cc���US-
n[U5S::amSX3--
nSU-S-U-S-U-S-U-S-U-S	-U-S
-U-S-U-nSU-S
-U-S-U-S-U-S-U-S-U-S-U-S-nXV-nXU--$US::aUOSU-
n[[U5*5nUS::a^US-
nSU-S-U-S-U-S-U-S-U-S-U-S-U-S-nSU-S -U-S!-U-S"-U-S#-U-S$-U-S%-U-S-nO]US-
nS&U-S'-U-S(-U-S)-U-S*-U-S+-U-S,-U-S--nS.U-S/-U-S0-U-S1-U-S2-U-S3-U-S4-U-S-nXV-nUS:aU*nXU--$)5Nr�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�@�F�>g�tcI,\�>g�ŝ���I?g*F2�v�?g�C4�?g��O�1�?)r#r"r')�pr^�sigmar��rr�r�rfs        rC�_normal_dist_inv_cdfr��s���	
�C��A��A�w�%���q�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����Y���
�#�X��3��7�A��c�!�f�W�
�A��C�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����	�	�A��3�w�
�B��
�U���rB)r�c��\rSrSrSrSSS.rS"Sjr\S5rSS	.S
jr	Sr
SrS
rS#Sjr
SrSr\S5r\S5r\S5r\S5r\S5rSrSrSrSrSrSr\rSr\rSrSr Sr!S r"S!r#Sr$g)$ri�z(Normal distribution of a random variablez(Arithmetic mean of a normal distributionz+Standard deviation of a normal distribution��_mu�_sigmac�f�US:a[S5e[U5Ul[U5Ulg)zDNormalDist where mu is the mean and sigma is the standard deviation.r�zsigma must be non-negativeN)rrxr�r�)�selfr^r�s   rC�__init__�NormalDist.__init__�s+���3�;�!�">�?�?���9����E�l��rBc��U"[U56$)z5Make a normal distribution instance from sample data.)re)�clsrZs  rC�from_samples�NormalDist.from_samples�s���K��%�&�&rBN��seedc��Uc[RO[R"U5Rn[nURnURn[SU5Vs/sHot"U"5XV5PM sn$s snf)z=Generate *n* samples for a given mean and standard deviation.N)�random�Randomr�r�r�r)r�rKr��rnd�inv_cdfr^r�r�s        rC�samples�NormalDist.samples�s^��#�|�f�m�m����t�1D�1K�1K��&��
�X�X������39�$��?�C�?�a����r�)�?�C�C��Cs� A:c��URUR-nU(d[S5eXR-
n[X3-SU--5[	[
U-5-$)z4Probability density function.  P(x <= X < x+dx) / dxz$pdf() not defined when sigma is zerog�)r�rr�r$r"r&)r�rfr�diffs    rCr9�NormalDist.pdf�sR���;�;����,���!�"H�I�I��8�8�|���4�;�$��/�2�3�d�3��>�6J�J�JrBc��UR(d[S5eSS[XR-
UR[--5--$)z,Cumulative distribution function.  P(X <= x)z$cdf() not defined when sigma is zeror�r�)r�rr%r��_SQRT2�r�rfs  rCr@�NormalDist.cdf�s>���{�{�!�"H�I�I��c�C��X�X��$�+�+��2F� G�H�H�I�IrBc�p�US::dUS:�a[S5e[XRUR5$)a#Inverse 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.0)rr�r�r�)r�r�s  rCr��NormalDist.inv_cdfs2��
��8�q�C�x�!�"H�I�I�#�A�x�x����=�=rBc�f�[SU5Vs/sHo RX!-5PM sn$s snf)aFDivide 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.
rE)rSr�)r�rKr�s   rCr�NormalDist.quantiless+��.3�1�a�[�9�[����Q�U�#�[�9�9��9s�.c	�4�[U[5(d[S5eXp2URUR4URUR4:aX2p2UR
UR
pTU(aU(d[
S5eXT-
n[URUR-
5nU(d%S[USUR-[--5-
$URU-URU--
nURUR-[Xw-U[XT-5--5-n	X�-U-n
X�-
U-nS[URU
5URU
5-
5[URU5URU5-
5--
$)azCompute 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�r9)
r�rryr�r�rrr#r%r�r"r'r@)r��other�X�Y�X_var�Y_var�dvr�r��b�x1�x2s            rC�overlap�NormalDist.overlapsN�� �%��,�,��B�C�C��1�
�H�H�a�e�e�����!�%�%�0�0��q��z�z�1�:�:�u��E�!�"L�M�M�
�]��
�!�%�%�!�%�%�-�
 �����R�3����>�F�#:�;�<�<�<�
�E�E�E�M�A�E�E�E�M�)��
�H�H�q�x�x��$�r�w��c�%�-�6H�1H�'H�"I�I���e�r�\���e�r�\���d�1�5�5��9�q�u�u�R�y�0�1�D����r��Q�U�U�2�Y�9N�4O�O�P�PrBc�p�UR(d[S5eXR-
UR-$)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)r�rr�r�s  rC�zscore�NormalDist.zscore=s,���{�{�!�"K�L�L��H�H�����+�+rBc��UR$)z+Arithmetic mean of the normal distribution.�r��r�s rCr�NormalDist.meanH�
���x�x�rBc��UR$)z,Return the median of the normal distributionr�r�s rCr
�NormalDist.medianMr�rBc��UR$)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 rCr�NormalDist.modeRs
���x�x�rBc��UR$)z.Standard deviation of the normal distribution.�r�r�s rCr�NormalDist.stdev[s���{�{�rBc�4�URUR-$)z!Square of the standard deviation.r�r�s rCr�NormalDist.variance`s���{�{�T�[�[�(�(rBc���[U[5(aA[URUR-[URUR55$[URU-UR5$)a:Add 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�rr�r!r��r�r�s  rC�__add__�NormalDist.__add__e�R���b�*�%�%��b�f�f�r�v�v�o�u�R�Y�Y��	�	�/J�K�K��"�&�&�2�+�r�y�y�1�1rBc���[U[5(aA[URUR-
[URUR55$[URU-
UR5$)aCSubtract 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.
r�r�s  rC�__sub__�NormalDist.__sub__sr�rBc�`�[URU-UR[U5-5$)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.
�rr�r�r#r�s  rC�__mul__�NormalDist.__mul__��&���"�&�&�2�+�r�y�y�4��8�';�<�<rBc�`�[URU-UR[U5-5$)z�Divide 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.
r�r�s  rC�__truediv__�NormalDist.__truediv__�r�rBc�B�[URUR5$)zReturn a copy of the instance.�rr�r��r�s rC�__pos__�NormalDist.__pos__�s���"�&�&�"�)�)�,�,rBc�D�[UR*UR5$)z(Negates mu while keeping sigma the same.r�r�s rC�__neg__�NormalDist.__neg__�s���2�6�6�'�2�9�9�-�-rBc��X-
*$)z<Subtract a NormalDist from a constant or another NormalDist.r<r�s  rC�__rsub__�NormalDist.__rsub__�s����z�rBc��[U[5(d[$URUR:H=(a URUR:H$)zFTwo NormalDist objects are equal if their mu and sigma are both equal.)r�r�NotImplementedr�r�r�s  rC�__eq__�NormalDist.__eq__�s:���"�j�)�)�!�!��v�v�����:�B�I�I����$:�:rBc�D�[URUR45$)zCNormalDist objects hash equal if their mu and sigma are both equal.)�hashr�r�r�s rC�__hash__�NormalDist.__hash__�s���T�X�X�t�{�{�+�,�,rBc�j�[U5RSUR<SUR<S3$)Nz(mu=z, sigma=�))rRr=r�r�r�s rC�__repr__�NormalDist.__repr__�s.���t�*�%�%�&�d�4�8�8�,�h�t�{�{�o�Q�O�OrBc�2�URUR4$rGr�r�s rC�__getstate__�NormalDist.__getstate__�s���x�x����$�$rBc�"�UuUlUlgrGr�)r��states  rC�__setstate__�NormalDist.__setstate__�s�� %����$�+rB)r�r�)r�)%r=r>r?r@rK�	__slots__r��classmethodr�r�r9r@r�rr�r��propertyrr
rrrr�r�r�r�r�r��__radd__r��__rmul__r�r�r�r�r�rAr<rBrCrr�s	��.�
:�?��I�
#��'��'�"&�D�K�J�>�	:� Q�D	,������������������)��)�2�2�=�=�-�.��H���H�;�-�P�%�&rBrc� ^^^^�UUUU4SjnU$)Nc�>�T"U5n[T"U5U-
=n5T:�a)XT"U5--n[T"U5U-
=n5T:�aM)U$)u=Return x such that f(x) ≈ y within the specified tolerance.r)rfrfr�r��f_inv_estimate�f_prime�	tolerances   ����rC�f_inv�_newton_raphson.<locals>.f_inv�sY����1����!�A�$��(�"�$�#�i�/�
���
�"�"�A��!�A�$��(�"�$�#�i�/��rBr<)r�r�r�r�r�s```` rC�_newton_raphsonr��s������LrBc��US::aSU4OSSU-
4upSU-S-S-
nUSs=:�aS:aO X!-$US[S	U-S
-5--
nX!-$)Nr�r���r9g��鼹A�?g����Mbp?gV-����?gM�p�^v�?g��$2h@g_���@r-�r��signrfs   rC�_quartic_invcdf_estimater�sk���s�(�s�A�h��s�Q�w��G�D�	�q��_�$�s�*�A��E��E���8�O�	
�[�3�{�Q��1A�A�B�
B�B���8�OrBc�6�SUS--SUS---
SU--S-$r!r<rs rCr�r��s'��$��A��+��a��d�
�*�U�Q�Y�6��<rBc��SSX--
S--$rr<rs rCr�r�������q�u��� 2�2rB)r�r�r�c�F�US::aSU4OSSU-
4upSU-S-S-
nX!-$)Nr�r�r�r9g�c���?r<rs   rC�_triweight_invcdf_estimater�s8���s�(�s�A�h��s�Q�w��G�D�	�q��'�'�#�-�A��8�OrBc�B�SSUS--SUS---US--
U--S-$r(r<rs rCr�r��s1��%�4��1��9�s�1�a�4�x�/�!�Q�$�6��:�;�c�ArBc��SSX--
S--$r%r<rs rCr�r��rrBc�$�[USU-
-5$)NrE)r'�r�s rCr�r��s��#�a�1�q�5�k�*rBc�>�[[U[-S-55$)Nr�)r'r/r,rs rCr�r��s���S��R����]�+rBc��SU-S-
$�Nr�rEr<rs rCr�r��s��Q�q�S�1�WrBc�P�S[[SU-S-
5[-S-5-$)Nr�rEr�)r-r3r,rs rCr�r��s$��1�s�D��1��Q��K�"�$4��#9�:�:rBc�X�US:a[SU-5S-
$S[SSU--
5-
$)Nr�r�rE)r"rs rCr�r��s/��Q��W�D��1��I��M�K�!�d�1�q��s�7�m�:K�KrBc�8�S[SU-S-
5-[-$r)r1r,rs rCr�r��s���D��1��q��M�)�B�.rB)	r�r�rrrrr#rr*r�rrrrrrr�c�^^^^^	�[T5nU(d[S5e[TS[[45(d[S5eTS::a[ST<35e[RU5mTc[SU<35e[RU5nURm	URmUUUUU	4SjnST<S	U<3UlU$)
a<Return a function that makes a random selection from the estimated
probability density function created by kde(data, h, kernel).

Providing a *seed* allows reproducible selections within a single
thread.  The seed may be an integer, float, str, or bytes.

A StatisticsError will be raised if the *data* sequence is empty.

Example:

>>> data = [-2.1, -1.3, -0.4, 1.9, 5.1, 6.2]
>>> rand = kde_random(data, h=1.5, seed=8675309)
>>> new_selections = [rand() for i in range(10)]
>>> [round(x, 1) for x in new_selections]
[0.7, 6.2, 1.2, 6.9, 7.0, 1.8, 2.5, -0.5, -1.8, 5.6]

r�rr�r�r�r.c�6>�T"T5TT"T"55--$rGr<)�choicerZr4�
kernel_invcdfr�s�����rC�rand�kde_random.<locals>.rand
s����d�|�a�-���"9�9�9�9rBzRandom KDE selection with h=rJ)
r�rr�rYrxry�_kernel_invcdfsrQ�_randomr�r�rrK)
rZr4rLr�rK�prngrrrr�s
``     @@@rCr
r
�s����$	�D�	�A���3�4�4��d�1�g��U�|�,�,��C�D�D��C�x�� E�1�&�I�J�J�#�'�'��/�M���� 5�f�Z�@�A�A��>�>�$��D�
�[�[�F�
�[�[�F�:�:�3��v�]�6�+�F�D�L��KrBrG)znegative value)r�)r�)g�-���q=)drK�__all__rtr�r��sys�	fractionsr�decimalr�	itertoolsrrr�bisectrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3�	functoolsr4�operatorr5�collectionsr6r7r8r�rrrrcrprUrXrTr�r�r�rxr�rYr��
float_info�mant_digr��__annotations__r�r�rrrrr
rrrrrr	rrrrrrerhrrrxrr��_statistics�ImportErrorrr�r�_quartic_invcdfr�_triweight_invcdfr�rr
r<rBrC�<module>r+s���h�T��2��
�
���,�,�,�E�E�E�K�K�K���8�8�	
�c���
��	�j�	�3�l&�R �4�>+�\�$���I�Q�3�4�PU�;�3�l��������3�>�>�2�2�2�Q�6���6�
#�3�
#�3�
#�5�
#��S��S��W��<"�,!�H �F5,�p+�0 �,�&E+�PB�<K�(Q��Q�r�;�-4�l)%�X&�R?�$?�$
4����5��U��:�8$,�-H�`�0�2H�I��05�7>�zG�V	�0�
\&�\&�B��"�-�<�2�4��
�
$�/�A�2�4���l�"�"�*�+�$�:��"�K�.�
��+�8�4����,�]�;��	��"1�+�">����-�i�8��
��)��)��i�	��	�s�0G*�*G3�2G3
© 2025 GrazzMean-Shell