AlkantarClanX12

Your IP : 18.116.85.102


Current Path : /opt/alt/python33/lib64/python3.3/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/__pycache__/random.cpython-33.pyo

�
��f<dc@sdZddlmZddlmZmZddl	m
ZmZ
mZmZmZddl	mZmZmZmZddlmZddlm Z!m"Z#ddl$m%Z&d	d
ddd
ddddddddddddddddddgZ'd e
d!�ed"�Z(d"eZ)ed#�Z*d$ed%�Z+d&Z,d'e,Z-dd(l.Z.Gd)d	�d	e.j/�Z/Gd*d�de/�Z0d+d,�Z1d-d.d/�Z2e/�Z3e3j4Z4e3j5Z5e3j6Z6e3j7Z7e3j8Z8e3j9Z9e3j:Z:e3j;Z;e3j<Z<e3j=Z=e3j>Z>e3j?Z?e3j@Z@e3jAZAe3jBZBe3jCZCe3jDZDe3jEZEe3jFZFe3jGZGe3jHZHeId0kr{e2�nd(S(1u�Random variable generators.

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

    sequences
    ---------
           pick random element
           pick 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.

i(uwarn(u
MethodTypeuBuiltinMethodType(uloguexpupiueuceil(usqrtuacosucosusin(uurandom(uSetuSequence(usha512uRandomuseedurandomuuniformurandintuchoiceusampleu	randrangeushuffleu
normalvariateulognormvariateuexpovariateuvonmisesvariateugammavariateu
triangularugaussubetavariateu
paretovariateuweibullvariateugetstateusetstateugetrandbitsuSystemRandomig�?g@g@g�?g@i5iNcs�|EeZdZdZdZd7dd�Zd7d�fdd�Z�fdd	�Z�fd
d�Z	dd
�Z
dd�Zdd�Zd7de
dd�Zdd�Ze
de>eeedd�Zdd�Zd7dd�Zdd�Zdd �Zd!d"d7d#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z d3d4�Z!d5d6�Z"�S(8uRandomu�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.

    icCs|j|�d|_dS(ueInitialize an instance.

        Optional argument x controls seeding, as for Random.seed().
        N(useeduNoneu
gauss_next(uselfux((u+/opt/alt/python33/lib64/python3.3/random.pyu__init__Ts
uRandom.__init__ic
s�|dkrbytjtd�d�}Wqbtk
r^ddl}t|j�d�}YqbXn|dkr�t|ttt	f�r�t|t�r�|j
�}n|t|�j�7}tj|d�}q�nt
�j|�d|_dS(u�Initialize internal state from hashable object.

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

        For version 2 (the default), all of the bits are used if *a* is a str,
        bytes, or bytearray.  For version 1, the hash() of *a* is used instead.

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

        i ubigiNii(uNoneuintu
from_bytesu_urandomuNotImplementedErrorutimeu
isinstanceustrubytesu	bytearrayuencodeu_sha512udigestusuperuseedu
gauss_next(uselfuauversionutime(u	__class__(u+/opt/alt/python33/lib64/python3.3/random.pyuseed]s

uRandom.seedcs|jt�j�|jfS(u9Return internal state; can be passed to setstate() later.(uVERSIONusuperugetstateu
gauss_next(uself(u	__class__(u+/opt/alt/python33/lib64/python3.3/random.pyugetstate{suRandom.getstatecs�|d}|dkr;|\}}|_t�j|�n�|dkr�|\}}|_ytdd�|D��}Wn.tk
r�}zt|�WYdd}~XnXt�j|�ntd||jf��dS(u:Restore internal state from object returned by getstate().iiicss|]}|dVqdS(ii Nl((u.0ux((u+/opt/alt/python33/lib64/python3.3/random.pyu	<genexpr>�su"Random.setstate.<locals>.<genexpr>Nu?state with version %s passed to Random.setstate() of version %s(u
gauss_nextusuperusetstateutupleu
ValueErroru	TypeErroruVERSION(uselfustateuversionu
internalstateue(u	__class__(u+/opt/alt/python33/lib64/python3.3/random.pyusetstates
uRandom.setstatecCs
|j�S(N(ugetstate(uself((u+/opt/alt/python33/lib64/python3.3/random.pyu__getstate__�suRandom.__getstate__cCs|j|�dS(N(usetstate(uselfustate((u+/opt/alt/python33/lib64/python3.3/random.pyu__setstate__�suRandom.__setstate__cCs|jf|j�fS(N(u	__class__ugetstate(uself((u+/opt/alt/python33/lib64/python3.3/random.pyu
__reduce__�suRandom.__reduce__ic
Cs�||�}||kr'td��n|d	kr[|dkrL|j|�Std��n||�}||kr�td��n||}|dkr�|dkr�||j|�S|dkr�td|||f��n||�}||krtd��n|dkr%||d|}	n-|dkrF||d|}	ntd��|	dkrmtd��n|||j|	�S(
u�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.

        u!non-integer arg 1 for randrange()iuempty range for randrange()u non-integer stop for randrange()iu'empty range for randrange() (%d,%d, %d)u non-integer step for randrange()uzero step for randrange()N(u
ValueErroruNoneu
_randbelow(
uselfustartustopustepu_intuistartuistopuwidthuistepun((u+/opt/alt/python33/lib64/python3.3/random.pyu	randrange�s4


uRandom.randrangecCs|j||d�S(uJReturn random integer in range [a, b], including both end points.
        i(u	randrange(uselfuaub((u+/opt/alt/python33/lib64/python3.3/random.pyurandint�suRandom.randintc
Cs�|j}||j�|ks0||�|krk|j�}||�}	x|	|krf||�}	qKW|	S|j}
||kr�td�||
�|�S||}|||}|
�}	x|	|kr�|
�}	q�W||	|�|S(uCReturn a random int in the range [0,n).  Raises ValueError if n==0.u�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.(ugetrandbitsurandomu
bit_lengthu_warn(
uselfunuintumaxsizeutypeuMethodu
BuiltinMethodugetrandbitsukururandomuremulimit((u+/opt/alt/python33/lib64/python3.3/random.pyu
_randbelow�s"	'	

	
uRandom._randbelowcCsBy|jt|��}Wntk
r9td��YnX||S(u2Choose a random element from a non-empty sequence.u$Cannot choose from an empty sequence(u
_randbelowulenu
ValueErroru
IndexError(uselfusequi((u+/opt/alt/python33/lib64/python3.3/random.pyuchoice�s

u
Random.choicecCs�|dkrk|j}x�ttdt|���D]3}||d�}||||||<||<q1Wn`t}xWttdt|���D]:}||�|d�}||||||<||<q�WdS(u�x, random=random.random -> shuffle list x in place; return None.

        Optional arg random is a 0-argument function returning a random
        float in [0.0, 1.0); by default, the standard random.random.

        iN(uNoneu
_randbelowureversedurangeulenuint(uselfuxurandomu	randbelowuiuju_int((u+/opt/alt/python33/lib64/python3.3/random.pyushuffle�s	"$"uRandom.shufflecCs�t|t�rt|�}nt|t�s<td��n|j}t|�}d|koh|kns|td��nd	g|}d}|dkr�|dt	t
|dd��7}n||kr%t|�}x�t|�D]:}|||�}	||	||<|||d||	<q�Wnlt
�}
|
j}xWt|�D]I}||�}	x|	|
krt||�}	qYW||	�||	||<qDW|S(
u=Chooses 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.

        To choose a sample in a range of integers, use range as an argument.
        This is especially fast and space efficient for sampling from a
        large population:   sample(range(10000000), 60)
        u>Population must be a sequence or set.  For dicts, use list(d).iuSample larger than populationiiiiiN(u
isinstanceu_Setutupleu	_Sequenceu	TypeErroru
_randbelowulenu
ValueErroruNoneu_ceilu_logulisturangeusetuadd(uselfu
populationuku	randbelowunuresultusetsizeupooluiujuselecteduselected_add((u+/opt/alt/python33/lib64/python3.3/random.pyusamples6	
$		
u
Random.samplecCs||||j�S(uHGet a random number in the range [a, b) or [a, b] depending on rounding.(urandom(uselfuaub((u+/opt/alt/python33/lib64/python3.3/random.pyuuniformPsuRandom.uniformgg�?cCsx|j�}|dkrdn||||}||kr`d|}d|}||}}n|||||dS(u�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

        g�?g�?N(urandomuNone(uselfulowuhighumodeuuuc((u+/opt/alt/python33/lib64/python3.3/random.pyu
triangularVs	$

uRandom.triangularcCsh|j}xP|�}d|�}t|d|}||d}|t|�krPqq|||S(u\Normal distribution.

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

        g�?g�?g@(urandomu
NV_MAGICCONSTu_log(uselfumuusigmaurandomuu1uu2uzuzz((u+/opt/alt/python33/lib64/python3.3/random.pyu
normalvariateis
		
uRandom.normalvariatecCst|j||��S(u�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.

        (u_expu
normalvariate(uselfumuusigma((u+/opt/alt/python33/lib64/python3.3/random.pyulognormvariate�suRandom.lognormvariatecCstd|j��|S(u^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.

        g�?(u_logurandom(uselfulambd((u+/opt/alt/python33/lib64/python3.3/random.pyuexpovariate�suRandom.expovariatecCs|j}|dkr t|�Sd|}|td||�}xe|�}tt|�}|||}|�}	|	d||ks�|	d|t|�krEPqEqEd|}
|
|d|
|}|�}|dkr�|t|�t}
n|t|�t}
|
S(uFCircular 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���ư>g�?g�?(urandomuTWOPIu_sqrtu_cosu_piu_expu_acos(uselfumuukappaurandomusuruu1uzuduu2uqufuu3utheta((u+/opt/alt/python33/lib64/python3.3/random.pyuvonmisesvariate�s&	
		.
	uRandom.vonmisesvariatecCs|dks|dkr'td��n|j}|dkrtd|d�}|t}||}x�|�}d|ko�dkns�qgnd|�}t|d|�|}	|t|	�}
|||}|||	|
}|td|dks|t|�krg|
|Sqgn�|dkr_|�}
x|
dkrO|�}
q7Wt|
�|Sx�|�}
t|t}||
}|dkr�|d|}
nt|||�}
|�}|dkr�||
|dkr�Pq�qb|t|
�krbPqbqb|
|SdS(	uZGamma 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

        gu*gammavariate: alpha and beta must be > 0.0g�?g@gH�����z>g�P���?g@N(u
ValueErrorurandomu_sqrtuLOG4u_logu_expu
SG_MAGICCONSTu_e(uselfualphaubetaurandomuainvubbbucccuu1uu2uvuxuzuruuubup((u+/opt/alt/python33/lib64/python3.3/random.pyugammavariate�sJ	

	
*	
	
	uRandom.gammavariatecCs�|j}|j}d|_|dkrw|�t}tdtd|���}t|�|}t|�||_n|||S(u�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.

        g@g�?Ng�(urandomu
gauss_nextuNoneuTWOPIu_sqrtu_logu_cosu_sin(uselfumuusigmaurandomuzux2piug2rad((u+/opt/alt/python33/lib64/python3.3/random.pyugausss			
uRandom.gausscCs>|j|d�}|dkr"dS|||j|d�SdS(u�Beta distribution.

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

        g�?igN(ugammavariate(uselfualphaubetauy((u+/opt/alt/python33/lib64/python3.3/random.pyubetavariateNs
uRandom.betavariatecCs d|j�}d|d|S(u3Pareto distribution.  alpha is the shape parameter.g�?(urandom(uselfualphauu((u+/opt/alt/python33/lib64/python3.3/random.pyu
paretovariate`suRandom.paretovariatecCs'd|j�}|t|�d|S(ufWeibull distribution.

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

        g�?(urandomu_log(uselfualphaubetauu((u+/opt/alt/python33/lib64/python3.3/random.pyuweibullvariateisuRandom.weibullvariateN(#u__name__u
__module__u__qualname__u__doc__uVERSIONuNoneu__init__useedugetstateusetstateu__getstate__u__setstate__u
__reduce__uintu	randrangeurandintuBPFutypeu_MethodTypeu_BuiltinMethodTypeu
_randbelowuchoiceushuffleusampleuuniformu
triangularu
normalvariateulognormvariateuexpovariateuvonmisesvariateugammavariateugaussubetavariateu
paretovariateuweibullvariate(u
__locals__((u	__class__u+/opt/alt/python33/lib64/python3.3/random.pyuRandomDs6	,
>0H5	cBsT|EeZdZdZdd�Zdd�Zdd�Zdd	�ZeZZ	d
S(uSystemRandomu�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).
    cCstjtd�d�d?tS(u3Get the next random number in the range [0.0, 1.0).iubigi(uintu
from_bytesu_urandomu	RECIP_BPF(uself((u+/opt/alt/python33/lib64/python3.3/random.pyurandom~suSystemRandom.randomcCsr|dkrtd��n|t|�kr<td��n|dd}tjt|�d�}||d|?S(u:getrandbits(k) -> x.  Generates an int with k random bits.iu(number of bits must be greater than zerou#number of bits should be an integeriiubig(u
ValueErroruintu	TypeErroru
from_bytesu_urandom(uselfukunumbytesux((u+/opt/alt/python33/lib64/python3.3/random.pyugetrandbits�suSystemRandom.getrandbitscOsdS(u<Stub method.  Not used for a system random number generator.N(uNone(uselfuargsukwds((u+/opt/alt/python33/lib64/python3.3/random.pyuseed�suSystemRandom.seedcOstd��dS(uAMethod should not be called for a system random number generator.u*System entropy source does not have state.N(uNotImplementedError(uselfuargsukwds((u+/opt/alt/python33/lib64/python3.3/random.pyu_notimplemented�suSystemRandom._notimplementedN(
u__name__u
__module__u__qualname__u__doc__urandomugetrandbitsuseedu_notimplementedugetstateusetstate(u
__locals__((u+/opt/alt/python33/lib64/python3.3/random.pyuSystemRandomvs
cCsddl}t|d|j�d}d}d}d
}|j�}xVt|�D]H}	||�}
||
7}||
|
}t|
|�}t|
|�}qPW|j�}tt||d�ddd�||}t||||�}
td	||
||f�dS(Niutimesgg _�Biusec,uendu u!avg %g, stddev %g, min %g, max %gg _��(utimeuprintu__name__urangeuminumaxuroundu_sqrt(unufuncuargsutimeutotalusqsumusmallestulargestut0uiuxut1uavgustddev((u+/opt/alt/python33/lib64/python3.3/random.pyu_test_generator�s&
 
u_test_generatori�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(Ngg�?g{�G�z�?g�������?g@g�?g�������?g4@gi@g@(gg�?(gg�?(gg�?(g{�G�z�?g�?(g�������?g�?(g�������?g@(g�?g�?(g�������?g�?(g�?g�?(g@g�?(g4@g�?(gi@g�?(gg�?(g@g@gUUUUUU�?(gg�?gUUUUUU�?(	u_test_generatorurandomu
normalvariateulognormvariateuvonmisesvariateugammavariateugaussubetavariateu
triangular(uN((u+/opt/alt/python33/lib64/python3.3/random.pyu_test�s u_testu__main__(Ju__doc__uwarningsuwarnu_warnutypesu
MethodTypeu_MethodTypeuBuiltinMethodTypeu_BuiltinMethodTypeumathulogu_loguexpu_expupiu_piueu_euceilu_ceilusqrtu_sqrtuacosu_acosucosu_cosusinu_sinuosuurandomu_urandomucollections.abcuSetu_SetuSequenceu	_Sequenceuhashlibusha512u_sha512u__all__u
NV_MAGICCONSTuTWOPIuLOG4u
SG_MAGICCONSTuBPFu	RECIP_BPFu_randomuRandomuSystemRandomu_test_generatoru_testu_instuseedurandomuuniformu
triangularurandintuchoiceu	randrangeusampleushuffleu
normalvariateulognormvariateuexpovariateuvonmisesvariateugammavariateugaussubetavariateu
paretovariateuweibullvariateugetstateusetstateugetrandbitsu__name__(((u+/opt/alt/python33/lib64/python3.3/random.pyu<module>%sd("		
��4!