ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/random.cpython-35.opt-2.pyc



���]_g�@svddlmZddlmZmZddlm	Z
mZm
ZmZmZddlmZmZmZmZddlmZddlmZ m!Z"ddl#m$Z%dd	d
ddd
dddddddddddddddddgZ&ded �ed!�Z'd!eZ(e
d"�Z)d#e
d$�Z*d%Z+d&e+Z,dd'l-Z-Gd(d�de-j.�Z.Gd)d�de.�Z/d*d+�Z0d,d-d.�Z1e.�Z2e2j3Z3e2j4Z4e2j5Z5e2j6Z6e2j7Z7e2j8Z8e2j9Z9e2j:Z:e2j;Z;e2j<Z<e2j=Z=e2j>Z>e2j?Z?e2j@Z@e2jAZAe2jBZBe2jCZCe2jDZDe2jEZEe2jFZFe2jGZGeHd/krre1�d'S)0�)�warn)�
MethodType�BuiltinMethodType)�log�exp�pi�e�ceil)�sqrt�acos�cos�sin)�urandom)�Set�Sequence)�sha512�Random�seed�random�uniform�randint�choice�sample�	randrange�shuffle�
normalvariate�lognormvariate�expovariate�vonmisesvariate�gammavariate�
triangular�gauss�betavariate�
paretovariate�weibullvariate�getstate�setstate�getrandbits�SystemRandom�g�?g@g@g�?g@�5�NcsyeZdZdZddd�Zdd�fdd�Z�fdd	�Z�fd
d�Zdd
�Zdd�Z	dd�Z
ddedd�Zdd�Z
ede>eeedd�Zdd�Zddd�Zdd�Zdd �Zd!d"dd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Z �S)7r�NcCs|j|�d|_dS)N)r�
gauss_next)�self�x�r0�+/opt/alt/python35/lib64/python3.5/random.py�__init__Ts
zRandom.__init__r+c
su|dkr_ytjtd�d�}Wn4tk
r^ddl}t|j�d�}YnX|dkr�t|ttf�r�|r�t|d�d>nd}x&|D]}d|t|�Ad@}q�W|t	|�N}|d
kr�dn|}|d	krXt|ttt
f�rXt|t�r0|j�}|t|�j
�7}tj|d�}t�j|�d|_dS)Ni�	�bigr���iCBl����r+������)�int�
from_bytes�_urandom�NotImplementedError�time�
isinstance�str�bytes�ord�len�	bytearray�encode�_sha512�digest�superrr-)r.�a�versionr=r/�c)�	__class__r0r1r]s(
! 
zRandom.seedcs|jt�j�|jfS)N)�VERSIONrGr%r-)r.)rKr0r1r%�szRandom.getstatecs�|d}|dkr;|\}}|_t�j|�n�|dkr�|\}}|_ytdd�|D��}Wn.tk
r�}zt|�WYdd}~XnXt�j|�ntd||jf��dS)Nrr,r+css|]}|dVqdS)r+� Nlr0)�.0r/r0r0r1�	<genexpr>�sz"Random.setstate.<locals>.<genexpr>z?state with version %s passed to Random.setstate() of version %s)r-rGr&�tuple�
ValueError�	TypeErrorrL)r.�staterI�
internalstater)rKr0r1r&�s
zRandom.setstatecCs
|j�S)N)r%)r.r0r0r1�__getstate__�szRandom.__getstate__cCs|j|�dS)N)r&)r.rSr0r0r1�__setstate__�szRandom.__setstate__cCs|jf|j�fS)N)rKr%)r.r0r0r1�
__reduce__�szRandom.__reduce__r5c
Csp||�}||kr$td��|dkrU|dkrI|j|�Std��||�}||krytd��||}|dkr�|dkr�||j|�S|dkr�td|||f��||�}||kr�td��|dkr||d|}	n-|dkr7||d|}	ntd��|	dkr[td��|||j|	�S)	Nz!non-integer arg 1 for randrange()rzempty range for randrange()z non-integer stop for randrange()r5z'empty range for randrange() (%d,%d, %d)z non-integer step for randrange()zzero step for randrange())rQ�
_randbelow)
r.�start�stop�step�_int�istart�istop�width�istep�nr0r0r1r�s4


zRandom.randrangecCs|j||d�S)Nr5)r)r.rH�br0r0r1r�szRandom.randintc
Cs�|j}|j}||�|ks6||�|krq|j�}	||	�}
x|
|krl||	�}
qQW|
S||kr�td�||�|�S||}|||}|�}
x|
|kr�|�}
q�W||
|�|S)Nz�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.)rr'�
bit_length�_warn)
r.rar9�maxsize�type�Method�
BuiltinMethodrr'�k�r�rem�limitr0r0r1rX�s"		$

	
zRandom._randbelowcCsBy|jt|��}Wntk
r9td��YnX||S)Nz$Cannot choose from an empty sequence)rXrBrQ�
IndexError)r.�seq�ir0r0r1rs

z
Random.choicecCs�|dkrk|j}x�ttdt|���D]3}||d�}||||||<||<q1Wn`t}xWttdt|���D]:}||�|d�}||||||<||<q�WdS)Nr5)rX�reversed�rangerBr9)r.r/r�	randbelowro�jr\r0r0r1rs		"$"zRandom.shufflecCs�t|t�rt|�}t|t�s6td��|j}t|�}d|kob|knsstd��dg|}d}|dkr�|dtt	|dd��7}||krt
|�}x�t|�D]:}|||�}	||	||<|||d||	<q�Wnlt�}
|
j
}xWt|�D]I}||�}	x|	|
krh||�}	qMW||	�||	||<q8W|S)	Nz>Population must be a sequence or set.  For dicts, use list(d).rzSample larger than population��r)r,r5)r>�_SetrP�	_SequencerRrXrBrQ�_ceil�_log�listrq�set�add)r.�
populationrirrra�result�setsize�poolrors�selected�selected_addr0r0r1r!s6	
!		
z
Random.samplecCs||||j�S)N)r)r.rHrbr0r0r1r_szRandom.uniformgg�?cCs�|j�}y(|dkr!dn||||}Wntk
rL|SYnX||krzd|}d|}||}}|||||dS)Ng�?g�?)r�ZeroDivisionError)r.�low�high�mode�urJr0r0r1r es	(
	


zRandom.triangularcCsf|j}xN|�}d|�}t|d|}||d}|t|�krPqW|||S)Ng�?g�?g@)r�
NV_MAGICCONSTry)r.�mu�sigmar�u1�u2�z�zzr0r0r1r{s
		
zRandom.normalvariatecCst|j||��S)N)�_expr)r.r�r�r0r0r1r�szRandom.lognormvariatecCstd|j��|S)Ng�?)ryr)r.�lambdr0r0r1r�szRandom.expovariatecCs|j}|dkr t|�Sd|}|td||�}xc|�}tt|�}|||}|�}	|	d||ks�|	d|t|�krEPqEWd|}
|
|d|
|}|�}|dkr�|t|�t}
n|t|�t}
|
S)Ng���ư>g�?g�?)r�TWOPI�_sqrt�_cos�_pir��_acos)r.r��kappar�srjr�r��dr��q�f�u3�thetar0r0r1r�s&	
		.
	zRandom.vonmisesvariatecCs|dks|dkr$td��|j}|dkrtd|d�}|t}||}x�|�}d|ko�dkns�qdd|�}t|d|�|}	|t|	�}
|||}|||	|
}|td|dks|t|�krd|
|SqdWn�|dkrZ|�}
x|
dkrJ|�}
q2Wt|
�|Sx�|�}
t|t}||
}|dkr�|d|}
nt|||�}
|�}|dkr�||
|dkr�Pq]|t|
�kr]Pq]W|
|SdS)Ngz*gammavariate: alpha and beta must be > 0.0g�?g@gH�����z>g�P���?g@)rQrr��LOG4ryr��
SG_MAGICCONST�_e)r.�alpha�betar�ainv�bbb�cccr�r��vr/r�rjr�rb�pr0r0r1r�sJ	

	
*	
	
	zRandom.gammavariatecCs�|j}|j}d|_|dkrt|�t}tdtd|���}t|�|}t|�||_|||S)Ng@g�?g�)rr-r�r�ryr��_sin)r.r�r�rr��x2pi�g2radr0r0r1r!+s			
zRandom.gausscCs>|j|d�}|dkr"dS|||j|d�SdS)Ng�?rg)r)r.r�r��yr0r0r1r"`s
zRandom.betavariatecCs d|j�}d|d|S)Ng�?)r)r.r�r�r0r0r1r#rszRandom.paretovariatecCs'd|j�}|t|�d|S)Ng�?)rry)r.r�r�r�r0r0r1r${szRandom.weibullvariate)!�__name__�
__module__�__qualname__rLr2rr%r&rUrVrWr9rr�BPFrf�_MethodType�_BuiltinMethodTyperXrrrrr rrrrrr!r"r#r$r0r0)rKr1rDs4	),
>0H5	c@sJeZdZdd�Zdd�Zdd�Zdd�ZeZZd	S)
r(cCstjtd�d�d?tS)Nr6r3r,)r9r:r;�	RECIP_BPF)r.r0r0r1r�szSystemRandom.randomcCsl|dkrtd��|t|�kr6td��|dd}tjt|�d�}||d|?S)Nrz(number of bits must be greater than zeroz#number of bits should be an integerr6�r3)rQr9rRr:r;)r.ri�numbytesr/r0r0r1r'�szSystemRandom.getrandbitscOsdS)Nr0)r.�args�kwdsr0r0r1r�szSystemRandom.seedcOstd��dS)Nz*System entropy source does not have state.)r<)r.r�r�r0r0r1�_notimplemented�szSystemRandom._notimplementedN)	r�r�r�rr'rr�r%r&r0r0r0r1r(�s

cCsddl}t|d|j�d}d}d}d
}|j�}xVt|�D]H}	||�}
||
7}||
|
}t|
|�}t|
|�}qPW|j�}tt||d�ddd�||}t||||�}
td	||
||f�dS)Nr�timesgg _�Br,zsec,�end� z"avg %g, stddev %g, min %g, max %g
g _��)r=�printr�rq�min�max�roundr�)ra�funcr�r=�total�sqsum�smallest�largest�t0ror/�t1�avg�stddevr0r0r1�_test_generator�s&
 
r�i�cCst|tf�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)N���?�{�G�z�?皙�����?�@��?��������?�4@�i@�@)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r��UUUUUU�?)r�r�r�)	r�rrrrrr!r"r )�Nr0r0r1�_test�s r��__main__)I�warningsrrd�typesrr�rr��mathrryrr�rr�rr�r	rxr
r�rr�rr�r
r��osrr;�_collections_abcrrvrrw�hashlibrrE�__all__r�r�r�r�r�r��_randomrr(r�r��_instrrrr rrrrrrrrrrr!r"r#r$r%r&r'r�r0r0r0r1�<module>'sb("		
��F!																						

Zerion Mini Shell 1.0