ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python39/lib64/python3.9/__pycache__/random.cpython-39.pyc

a

���e�z�@s�dZddlmZddlmZmZm	Z
mZm
ZddlmZmZmZmZddlmZmZddlmZddlmZ m!Z"ddl#m$Z%m&Z'dd	l(m(Z)dd
lZ*dd
l+Z+zddl,m-Z,Wne.y�ddl/m-Z,Yn0gd�Z0d
ed�ed�Z1ed�Z2ded�Z3dZ4de4Z5Gdd�de+j6�Z6Gdd�de6�Z7e6�Z8e8j9Z9e8j:Z:e8j;Z;e8j<Z<e8j=Z=e8j>Z>e8j?Z?e8j@Z@e8jAZAe8jBZBe8jCZCe8jDZDe8jEZEe8jFZFe8jGZGe8jHZHe8jIZIe8jJZJe8jKZKe8jLZLe8jMZMe8jNZNe8jOZOdd�ZPd!dd�ZQeRe*d��r�e*jSe8j9d�eTd k�r�eQ�d
S)"a�Random variable generators.

    bytes
    -----
           uniform bytes (values between 0 and 255)

    integers
    --------
           uniform within range

    sequences
    ---------
           pick random element
           pick random sample
           pick weighted random sample
           generate random permutation

    distributions on the real line:
    ------------------------------
           uniform
           triangular
           normal (Gaussian)
           lognormal
           negative exponential
           gamma
           beta
           pareto
           Weibull

    distributions on the circle (angles 0 to 2pi)
    ---------------------------------------------
           circular uniform
           von Mises

General notes on the underlying Mersenne Twister core generator:

* The period is 2**19937-1.
* It is one of the most extensively tested generators in existence.
* The random() method is implemented in C, executes in a single Python step,
  and is, therefore, threadsafe.

�)�warn)�log�exp�pi�e�ceil)�sqrt�acos�cos�sin)�tau�floor)�urandom)�Set�Sequence)�
accumulate�repeat)�bisectN)�sha512)�Random�SystemRandom�betavariate�choice�choices�expovariate�gammavariate�gauss�getrandbits�getstate�lognormvariate�
normalvariate�
paretovariate�	randbytes�randint�random�	randrange�sample�seed�setstate�shuffle�
triangular�uniform�vonmisesvariate�weibullvariate�g��@�@��?�@�5�cs*eZdZdZdZdBdd�ZdC�fdd�	Z�fd	d
�Z�fdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
de>fdd�Ze
Zdd�ZdDdd�Zdd�Zd d!�ZdEd"d#�Zdd$�d%d&�ZdFddd'�d(d)�Zd*d+�ZdGd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"�Z#S)Hra�Random number generator base class used by bound module functions.

    Used to instantiate instances of Random to get generators that don't
    share state.

    Class Random can also be subclassed if you want to use a different basic
    generator of your own devising: in that case, override the following
    methods:  random(), seed(), getstate(), and setstate().
    Optionally, implement a getrandbits() method so that randrange()
    can cover arbitrarily large ranges.

    �NcCs|�|�d|_dS)zeInitialize an instance.

        Optional argument x controls seeding, as for Random.seed().
        N)r'�
gauss_next)�self�x�r9�+/opt/alt/python39/lib64/python3.9/random.py�__init__us
zRandom.__init__r4cs|dkr�t|ttf�r�t|t�r*|�d�n|}|rBt|d�d>nd}tt|�D]}d||Ad@}qP|t|�N}|dkr~dn|}nj|d	kr�t|tttf�r�t|t�r�|��}t	�
|t|���d
�}n&t|t
d�t	ttttf�s�tdtd	�t��|�d|_dS)
a\Initialize internal state from a seed.

        The only supported seed types are None, int, float,
        str, bytes, and bytearray.

        None or no argument seeds from current time or from an operating
        system specific randomness source if available.

        If *a* is an int, all bits are used.

        For version 2 (the default), all of the bits are used if *a* is a str,
        bytes, or bytearray.  For version 1 (provided for reproducing random
        sequences from older versions of Python), the algorithm for str and
        bytes generates a narrower range of seeds.

        �zlatin-1r�iCBl����������r4�bigNz�Seeding based on hashing is deprecated
since Python 3.9 and will be removed in a subsequent version. The only 
supported seed types are: None, int, float, str, bytes, and bytearray.)�
isinstance�str�bytes�decode�ord�map�len�	bytearray�encode�int�
from_bytes�_sha512Zdigest�type�float�_warn�DeprecationWarning�superr'r6)r7�a�versionr8�c��	__class__r9r:r'~s"
�zRandom.seedcs|jt���|jfS)z9Return internal state; can be passed to setstate() later.)�VERSIONrQrr6�r7rUr9r:r�szRandom.getstatec
s�|d}|dkr*|\}}|_t��|�nv|dkr�|\}}|_ztdd�|D��}Wn*ty~}zt|�WYd}~n
d}~00t��|�ntd||jf��dS)z:Restore internal state from object returned by getstate().rr5r4css|]}|dVqdS)lNr9)�.0r8r9r9r:�	<genexpr>��z"Random.setstate.<locals>.<genexpr>Nz?state with version %s passed to Random.setstate() of version %s)r6rQr(�tuple�
ValueError�	TypeErrorrW)r7�staterSZ
internalstaterrUr9r:r(�s�zRandom.setstatecCs|��S�N)rrXr9r9r:�__getstate__�szRandom.__getstate__cCs|�|�dSr`)r()r7r_r9r9r:�__setstate__�szRandom.__setstate__cCs|jd|��fS)Nr9)rVrrXr9r9r:�
__reduce__�szRandom.__reduce__cKsJ|jD]>}d|jvrqFd|jvr.|j|_qFd|jvr|j|_qFqdS)aControl how subclasses generate random integers.

        The algorithm a subclass can use depends on the random() and/or
        getrandbits() implementation available to it and determines
        whether it can generate random integers from arbitrarily large
        ranges.
        �
_randbelowrr$N)�__mro__�__dict__�_randbelow_with_getrandbitsrd�_randbelow_without_getrandbits)�cls�kwargsrTr9r9r:�__init_subclass__�s	



zRandom.__init_subclass__cCs4|sdS|j}|��}||�}||kr0||�}q|S)z;Return a random int in the range [0,n).  Returns 0 if n==0.r)r�
bit_length)r7�nr�k�rr9r9r:rg�s
z"Random._randbelow_with_getrandbitsr<cCsj|j}||kr$td�t|�|�S|dkr0dS||}|||}|�}||krZ|�}qJt||�|S)z�Return a random int in the range [0,n).  Returns 0 if n==0.

        The implementation does not use getrandbits, but only random.
        z�Underlying random() generator does not supply 
enough bits to choose from a population range this large.
To remove the range limitation, add a getrandbits() method.r)r$rO�_floor)r7rm�maxsizer$Zrem�limitror9r9r:rh�sz%Random._randbelow_without_getrandbitscCs|�|d��|d�S)�Generate n random bytes.��little)r�to_bytes�r7rmr9r9r:r"szRandom.randbytesc	Cst|�}||krtd��|dur:|dkr2|�|�Std��t|�}||krRtd��||}|dkrx|dkrx||�|�S|dkr�td|||f��t|�}||kr�td��|dkr�||d|}n"|dkr�||d|}ntd	��|dkr�td��|||�|�S)
z�Choose a random item from range(start, stop[, step]).

        This fixes the problem with randint() which includes the
        endpoint; in Python this is usually not what you want.

        z!non-integer arg 1 for randrange()Nrzempty range for randrange()z non-integer stop for randrange()r<z(empty range for randrange() (%d, %d, %d)z non-integer step for randrange()zzero step for randrange())rJr]rd)	r7�start�stop�stepZistartZistop�widthZisteprmr9r9r:r%"s4

zRandom.randrangecCs|�||d�S)zJReturn random integer in range [a, b], including both end points.
        r<)r%�r7rR�br9r9r:r#NszRandom.randintcCs||�t|��S)z2Choose a random element from a non-empty sequence.)rdrG)r7�seqr9r9r:rWsz
Random.choicecCs�|durN|j}ttdt|���D]*}||d�}||||||<||<q nTtdtd�t}ttdt|���D]0}||�|d�}||||||<||<qpdS)z�Shuffle list x in place, and return None.

        Optional argument random is a 0-argument function returning a
        random float in [0.0, 1.0); if it is the default None, the
        standard random.random will be used.

        Nr<zuThe *random* parameter to shuffle() has been deprecated
since Python 3.9 and will be removed in a subsequent version.r4)rd�reversed�rangerGrOrPrp)r7r8r$�	randbelow�i�jr
r9r9r:r)\s	�zRandom.shuffle)�countscs�t�t�rtdtd�t���t�t�s0td��t��}|dur�tt	|���t��|kr`t
d�����}t|t�sztd��|dkr�t
d��|j
t|�|d	�}t����fd
d�|D�S|j}d|kr�|ks�nt
d��dg|}d
}	|dk�r|	dtt|dd��7}	||	k�r\t��}
t|�D]2}|||�}|
|||<|
||d|
|<�q&nNt�}
|
j}t|�D]8}||�}||
v�r�||�}�q|||��|||<�qp|S)amChooses k unique random elements from a population sequence or set.

        Returns a new list containing elements from the population while
        leaving the original population unchanged.  The resulting list is
        in selection order so that all sub-slices will also be valid random
        samples.  This allows raffle winners (the sample) to be partitioned
        into grand prize and second place winners (the subslices).

        Members of the population need not be hashable or unique.  If the
        population contains repeats, then each occurrence is a possible
        selection in the sample.

        Repeated elements can be specified one at a time or with the optional
        counts parameter.  For example:

            sample(['red', 'blue'], counts=[4, 2], k=5)

        is equivalent to:

            sample(['red', 'red', 'red', 'red', 'blue', 'blue'], k=5)

        To choose a sample from a range of integers, use range() for the
        population argument.  This is especially fast and space efficient
        for sampling from a large population:

            sample(range(10000000), 60)

        z\Sampling from a set deprecated
since Python 3.9 and will be removed in a subsequent version.r4zAPopulation must be a sequence.  For dicts or sets, use sorted(d).Nz2The number of counts does not match the populationzCounts must be integersrz)Total of counts must be greater than zero)rncsg|]}���|��qSr9r9)rY�s�rZ
cum_counts�
populationr9r:�
<listcomp>�r[z!Random.sample.<locals>.<listcomp>z,Sample larger than population or is negative��r.r5r<)rA�_SetrOrPr\�	_Sequencer^rG�list�_accumulater]�poprJr&r��_bisectrd�_ceil�_log�set�add)r7r�rnr�rm�totalZ
selectionsr��resultZsetsizeZpoolr�r�ZselectedZselected_addr9r�r:r&vsT5
�





z
Random.sample)�cum_weightsrncs�|j�t����dur�|durHt��d7�����fdd�td|�D�Sztt|���Wq�ty�t|t�sr�|}td|���d�Yq�0n|dur�td��t���kr�t	d���dd��dkr�t	d	��t
��d
�������fdd�td|�D�S)z�Return a k sized list of population elements chosen with replacement.

        If the relative weights or cumulative weights are not specified,
        the selections are made with equal probability.

        N�csg|]}�������qSr9r9�rYr�)r
rmr�r$r9r:r��r[z"Random.choices.<locals>.<listcomp>z4The number of choices must be a keyword argument: k=z2Cannot specify both weights and cumulative weightsz3The number of weights does not match the populationr>z*Total of weights must be greater than zeror<cs$g|]}������d���qS)rr9r�)rr��hir�r$r�r9r:r��s�)r$rGrp�_repeatr�r�r^rArJr]r�)r7r�Zweightsr�rnr9)rr�r
r�rmr�r$r�r:r�s<
��
�zRandom.choicescCs||||��S)zHGet a random number in the range [a, b) or [a, b] depending on rounding.�r$r|r9r9r:r+�szRandom.uniformr�r1cCsz|��}z |durdn||||}Wnty>|YS0||krbd|}d|}||}}|||t||�S)z�Triangular distribution.

        Continuous distribution bounded by given lower and upper limits,
        and having a given mode value in-between.

        http://en.wikipedia.org/wiki/Triangular_distribution

        N��?r1)r$�ZeroDivisionError�_sqrt)r7�low�high�mode�urTr9r9r:r*s	 

zRandom.triangularcCsP|j}|�}d|�}t|d|}||d}|t|�krqDq|||S)z\Normal distribution.

        mu is the mean, and sigma is the standard deviation.

        r1r�r0)r$�
NV_MAGICCONSTr�)r7�mu�sigmar$�u1�u2�zZzzr9r9r:r s
zRandom.normalvariatecCs`|j}|j}d|_|durT|�t}tdtd|���}t|�|}t|�||_|||S)z�Gaussian distribution.

        mu is the mean, and sigma is the standard deviation.  This is
        slightly faster than the normalvariate() function.

        Not thread-safe without a lock around calls.

        Ng�r1)r$r6�TWOPIr�r��_cos�_sin)r7r�r�r$r�Zx2piZg2radr9r9r:r,s
zRandom.gausscCst|�||��S)z�Log normal distribution.

        If you take the natural logarithm of this distribution, you'll get a
        normal distribution with mean mu and standard deviation sigma.
        mu can have any value, and sigma must be greater than zero.

        )�_expr )r7r�r�r9r9r:rRszRandom.lognormvariatecCstd|���|S)a^Exponential distribution.

        lambd is 1.0 divided by the desired mean.  It should be
        nonzero.  (The parameter would be called "lambda", but that is
        a reserved word in Python.)  Returned values range from 0 to
        positive infinity if lambd is positive, and from negative
        infinity to 0 if lambd is negative.

        r1)r�r$)r7Zlambdr9r9r:r\szRandom.expovariatecCs�|j}|dkrt|�Sd|}|td||�}|�}tt|�}|||}|�}	|	d||ks�|	d|t|�kr4q�q4d|}
|
|d|
|}|�}|dkr�|t|�t}
n|t|�t}
|
S)aFCircular data distribution.

        mu is the mean angle, expressed in radians between 0 and 2*pi, and
        kappa is the concentration parameter, which must be greater than or
        equal to zero.  If kappa is equal to zero, this distribution reduces
        to a uniform random angle over the range 0 to 2*pi.

        g���ư>r�r1)r$r�r�r��_pir��_acos)r7r�Zkappar$r�ror�r��dr��q�fZu3Zthetar9r9r:r,ms$
$zRandom.vonmisesvariatecCs~|dks|dkrtd��|j}|dkr�td|d�}|t}||}|�}d|kr`dksdqFqFd|�}t|d|�|}	|t|	�}
|||}|||	|
}|td|dks�|t|�krF|
|SqFn�|dkr�td|��|S|�}
t|t}||
}|dk�r$|d|}
nt|||�}
|�}|dk�r^||
|dk�rp�qrq�|t|
�kr�qrq�|
|SdS)	aZGamma distribution.  Not the gamma function!

        Conditions on the parameters are alpha > 0 and beta > 0.

        The probability distribution function is:

                    x ** (alpha - 1) * math.exp(-x / beta)
          pdf(x) =  --------------------------------------
                      math.gamma(alpha) * beta ** alpha

        r�z*gammavariate: alpha and beta must be > 0.0r1r/gH�����z>g�P���?r2N)r]r$r��LOG4r�r��
SG_MAGICCONST�_e)r7�alpha�betar$ZainvZbbbZcccr�r��vr8r�ror�r}�pr9r9r:r�s@
 

zRandom.gammavariatecCs(|�|d�}|r$|||�|d�SdS)z�Beta distribution.

        Conditions on the parameters are alpha > 0 and beta > 0.
        Returned values range between 0 and 1.

        r1r�)r)r7r�r��yr9r9r:r�szRandom.betavariatecCsd|��}d|d|S)z3Pareto distribution.  alpha is the shape parameter.r1r�)r7r�r�r9r9r:r!�szRandom.paretovariatecCs"d|��}|t|�d|S)zfWeibull distribution.

        alpha is the scale parameter and beta is the shape parameter.

        r1)r$r�)r7r�r�r�r9r9r:r-�szRandom.weibullvariate)N)Nr4)Nr<)N)N)r�r1N)$�__name__�
__module__�__qualname__�__doc__rWr;r'rr(rarbrcrkrg�BPFrhrdr"r%r#rr)r&rr+r*r rrrr,rrr!r-�
__classcell__r9r9rUr:res>

	*!

,	
c&
&
*Arc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZeZ	Z
dS)
rz�Alternate random number generator using sources provided
    by the operating system (such as /dev/urandom on Unix or
    CryptGenRandom on Windows).

     Not available on all systems (see os.urandom() for details).

    cCst�td�d�d?tS)z3Get the next random number in the range [0.0, 1.0).r=r@r5)rJrK�_urandom�	RECIP_BPFrXr9r9r:r$szSystemRandom.randomcCs<|dkrtd��|dd}t�t|�d�}||d|?S)z:getrandbits(k) -> x.  Generates an int with k random bits.rz#number of bits must be non-negativer=rtr@)r]rJrKr�)r7rnZnumbytesr8r9r9r:rs
zSystemRandom.getrandbitscCst|�S)rs)r�rwr9r9r:r"szSystemRandom.randbytescOsdS)z<Stub method.  Not used for a system random number generator.Nr9�r7�args�kwdsr9r9r:r'%szSystemRandom.seedcOstd��dS)zAMethod should not be called for a system random number generator.z*System entropy source does not have state.N)�NotImplementedErrorr�r9r9r:�_notimplemented)szSystemRandom._notimplementedN)r�r�r�r�r$rr"r'r�rr(r9r9r9r:r
src
s�ddlm}m}ddlm}|�}��fdd�t|�D�}|�}||�}	|||	�}
t|�}t|�}t||d�d|�d�j	���td	|	|
||f�dS)
Nr)�stdev�fmean)�perf_countercsg|]}����qSr9r9r��r��funcr9r:r�Xr[z#_test_generator.<locals>.<listcomp>z.3fz sec, z times z"avg %g, stddev %g, min %g, max %g
)
Z
statisticsr�r��timer�r��min�max�printr�)
rmr�r�r�Zmeanr�Zt0�data�t1Zxbarr�r�r�r9r�r:�_test_generatorSs
 r���cCs�t|td�t|td�t|td�t|td�t|td�t|td�t|td�t|td�t|td�t|td�t|td	�t|td
�t|td�t|td�t|td�t|td
�dS)Nr9)r�r1)g{�G�z�?r1)皙�����?r1)r�r/)r�r1)g�������?r1)r1r1)r/r1)g4@r1)gi@r1)�@r�)r�r1gUUUUUU�?)	r�r$r rr,rrrr*)�Nr9r9r:�_testds r��fork)Zafter_in_child�__main__)r�)Ur��warningsrrOZmathrr�rr�rr�rr�rr�rr�r	r�r
r�rr�rr�r
rp�osrr��_collections_abcrr�rr��	itertoolsrr�rr�rr��_osZ_randomrLr�ImportErrorZhashlib�__all__r�r�r�r�r�rr�_instr'r$r+r*r#rr%r&r)rr rrr,rrrr!r-rr(rr"r�r��hasattr�register_at_forkr�r9r9r9r:�<module>sr/
*,



Zerion Mini Shell 1.0