b374k
m1n1 1.01
Apache/2.2.15 (CentOS)
Linux obd60-6c49958d75-2q7cw 5.4.0-174-generic #193-Ubuntu SMP Thu Mar 7 14:29:28 UTC 2024 x86_64
uid=48(apache) gid=48(apache) groups=48(apache)
server ip : 104.21.65.202 | your ip : 10.244.126.0
safemode OFF
 >  / usr / lib64 / python2.6 /
Filename/usr/lib64/python2.6/random.pyo
Size24.52 kb
Permissionrw-r--r--
Ownerapache
Create time23-Dec-2025 17:41
Last modified20-Jun-2019 19:45
Last accessed22-Apr-2026 05:26
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
Ñò
§ÚêLc @ s�dZddklZddklZddklZl Z
ddk l Z
lZlZlZlZddk lZlZlZlZddklZ ddk!l"Z#d d
d d d
ddddddddddddddddddd d!gZ$d"ed#�ed$�Z%d$eZ&e
d%�Z'd&e
d'�Z(d(Z)d)e) Z*dd*k+Z+d e+i,fd+��YZ,de,fd,��YZ-d!e,fd-��YZ.d.�Z/d/d0�Z0e,�Z1e1i2Z2e1i3Z3e1i4Z4e1i5Z5e1i6Z6e1i7Z7e1i8Z8e1i9Z9e1i:Z:e1i;Z;e1i<Z<e1i=Z=e1i>Z>e1i?Z?e1i@Z@e1iAZAe1iBZBe1iCZCe1iDZDe1iEZEe1iFZFe1iGZGeHd1jo e0�nd*S(2sPRandom 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.
* Without a direct way to compute N steps forward, the semantics of
jumpahead(n) are weakened to simply jump to another distant state and rely
on the large period to avoid overlapping sequences.
* The random() method is implemented in C, executes in a single Python step,
and is, therefore, threadsafe.

iÿÿÿÿ(tdivision(twarn(t
MethodTypetBuiltinMethodType(tlogtexptpitetceil(tsqrttacostcostsin(turandom(thexlifytRandomtseedtrandomtuniformtrandinttchoicetsamplet randrangetshufflet
normalvariatetlognormvariatet expovariatetvonmisesvariatet gammavariatet
triangulartgausst betavariatet
paretovariatetweibullvariatetgetstatetsetstatet jumpaheadt WichmannHillt getrandbitst SystemRandomigà¿g@g@gð?g@i5iNcB s'eZdZdZdd�Zdd�Zd�Zd�Zd�Z d�Z
d�Z dd e dd
e
>d �Zd �Zee d
e
>eed
�Zd�Zde d�Zd�Zd�Zdddd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!RS(sÎRandom number generator base class used by bound module functions.

Used to instantiate instances of Random to get generators that don't
share state. Especially useful for multi-threaded programs, creating
a different instance of Random for each thread, and using the jumpahead()
method to ensure that the generated sequences seen by each thread don't
overlap.

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(), setstate() and jumpahead().
Optionally, implement a getrandbits() method so that randrange() can cover
arbitrarily large ranges.

icC s|i|�d|_dS(seInitialize an instance.

Optional argument x controls seeding, as for Random.seed().
N(RtNonet
gauss_next(tselftx((s/usr/lib64/python2.6/random.pyt__init__Zs
cC s�|djo[ytttd��d�}Wqhtj
o)ddk}t|i�d�}qhXntt|�i|�d|_ dS(sInitialize internal state from hashable object.

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

If a is not None or an int or long, hash(a) is used instead.
iiÿÿÿÿNi(
R(tlongt_hexlifyt_urandomtNotImplementedErrorttimetsuperRRR)(R*taR1((s/usr/lib64/python2.6/random.pyRcs
 cC s"|itt|�i�|ifS(s9Return internal state; can be passed to setstate() later.(tVERSIONR2RR"R)(R*((s/usr/lib64/python2.6/random.pyR"vscC sÔ|d}|djo,|\}}|_tt|�i|�n�|djog|\}}|_ytd�|D��}Wntj
o}t|�nXtt|�i|�ntd||if��dS(s:Restore internal state from object returned by getstate().iiics s#x|]}t|�dVqWdS(ii NI(R-(t.0R+((s/usr/lib64/python2.6/random.pys <genexpr>�s s?state with version %s passed to Random.setstate() of version %sN(R)R2RR#ttuplet
ValueErrort TypeErrorR4(R*tstatetversiont
internalstateR((s/usr/lib64/python2.6/random.pyR#zs


cC s
|i�S(N(R"(R*((s/usr/lib64/python2.6/random.pyt __getstate__�scC s|i|�dS(N(R#(R*R9((s/usr/lib64/python2.6/random.pyt __setstate__�scC s|id|i�fS(N((t __class__R"(R*((s/usr/lib64/python2.6/random.pyt
__reduce__�silc C s||�}||jo
td�n||joJ|djo0||jo|i|�S||i�|�Std�n||�}||jo
td�n||} |djoQ| djoD| |jo|||i| ��S||||i�| ��S|djotd||| f�n||�}
|
|jo
td�n|
djo| |
d|
} n-|
djo| |
d|
} n
td�| djo
td�n| |jo||
|i| �S||
||i�| �S( sChoose 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.
Do not supply the 'int', 'default', and 'maxwidth' arguments.
s!non-integer arg 1 for randrange()isempty range for randrange()s non-integer stop for randrange()is'empty range for randrange() (%d,%d, %d)s non-integer step for randrange()szero step for randrange()(R7t
_randbelowR( R*tstarttstoptsteptinttdefaulttmaxwidthtistarttistoptwidthtisteptn((s/usr/lib64/python2.6/random.pyR s@ 





 




 



 


cC s|i||d�S(sJReturn random integer in range [a, b], including both end points.
i(R(R*R3tb((s/usr/lib64/python2.6/random.pyRàsc
C sÊy
|i}Wntj
onzXt|i�|jpt|�|joO|d||dd��}||�} x| |jo||�} qxW| S||jotd�n||i�|�S(s£Return a random int in the range [0,n)

Handles the case where n has more bits than returned
by a single call to the underlying generator.
grÄZ|
ð?ig@sgUnderlying random() generator does not supply
enough bits to choose from a population range this large(R&tAttributeErrorttypeRt_warn(
R*RKt_logRDt _maxwidtht_Methodt_BuiltinMethodR&tktr((s/usr/lib64/python2.6/random.pyR@æs
) 

cC s|t|i�t|��S(s2Choose a random element from a non-empty sequence.(RDRtlen(R*tseq((s/usr/lib64/python2.6/random.pyRscC sx|djo
|i}nxWttdt|���D]:}||�|d�}||||||<||<q6WdS(s×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(R(RtreversedtxrangeRV(R*R+RRDtitj((s/usr/lib64/python2.6/random.pyRs 

c
C sÔt|�}d|jo
|jnp
td�n|i}t}d g|}d}|djo%|dtt|dd��7}n||jpt|d�obt|�}xt |�D]A} ||�|| �}
||
|| <||| d||
<qÁWnÇy�t
�} | i } xgt |�D]Y} ||�|�}
x%|
| jo||�|�}
qHW| |
�||
|| <q,WWnCt t
fj
o1t|t�o�n|it|�|�SX|S(
s8Chooses k unique random elements from a population sequence.

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 xrange as an argument.
This is especially fast and space efficient for sampling from a
large population: sample(xrange(10000000), 60)
issample larger than populationiiiitkeysiN(RVR7RRDR(t_ceilRPthasattrtlistRYtsettaddR8tKeyErrort
isinstanceRR6(
R*t
populationRTRKRt_inttresulttsetsizetpoolRZR[tselectedt selected_add((s/usr/lib64/python2.6/random.pyRs@% 
 

% 
  


cC s||||i�S(sHGet a random number in the range [a, b) or [a, b] depending on rounding.(R(R*R3RL((s/usr/lib64/python2.6/random.pyR_sggð?cC s||i�}|djodn||||}||jo%d|}d|}||}}n|||||dS(sÜ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(RR((R*tlowthightmodetutc((s/usr/lib64/python2.6/random.pyRes &


cC sj|i}xR|�}d|�}t|d|}||d}|t|� joPq q |||S(s\Normal distribution.

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

gð?gà?g@(Rt
NV_MAGICCONSTRP(R*tmutsigmaRtu1tu2tztzz((s/usr/lib64/python2.6/random.pyRxs
 
cC st|i||��S(sû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.

(t_expR(R*RqRr((s/usr/lib64/python2.6/random.pyR�scC s?|i}|�}x|djo
|�}qWt|� |S(s^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.

gH¯¼�ò×z>(RRP(R*tlambdRRn((s/usr/lib64/python2.6/random.pyR�s
 
cC s7|i}|djo t|�Sdtdd||�}|td|�d|}d||d|}x~|�}tt|�}d||||} ||| }
|�} | |
d|
jp| |
td|
�joPqsqs|�} | djo|tt| �}
n|tt| �}
|
S(sFCircular 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@g@gà?(RtTWOPIt_sqrtt_cost_piRwt_acos(R*RqtkappaRR3RLRURsRutfRoRttu3ttheta((s/usr/lib64/python2.6/random.pyR²s& 
   0 
cC s|djp
|djo
td�n|i}|djoêtd|d�}|t}||}x³|�}d|jo
djnpqhnd|�}t|d|�|} |t| �}
|||} ||| |
} | td| djp| t| �jo |
|Sqhnõ|djo7|�}
x|
djo
|�}
q@Wt|
� |Sx¥|�}
t|t}||
}|djo|d|}
nt|||� }
|�}|djo||
|djoPqqn|t|
�joPqnqn|
|SdS( sxGamma distribution. Not the gamma function!

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

gs*gammavariate: alpha and beta must be > 0.0gð?g@gH¯¼�ò×z>gËPÊÿÿï?g@N(R7RRztLOG4RPRwt
SG_MAGICCONSTt_e(R*talphatbetaRtainvtbbbtcccRsRttvR+RuRURnRLtp((s/usr/lib64/python2.6/random.pyRäsL 
 


 
,
 
 

 
 cC s�|i}|i}d|_|djoQ|�t}tdtd|���}t|�|}t|�||_n|||S(sØ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ð?N(RR)R(RyRzRPR{t_sin(R*RqRrRRutx2pitg2rad((s/usr/lib64/python2.6/random.pyR&s   

cC s@|i|d�}|djodS|||i|d�SdS(s�Beta distribution.

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

gð?igN(R(R*R�R�ty((s/usr/lib64/python2.6/random.pyR[s

cC s%d|i�}dt|d|�S(s3Pareto distribution. alpha is the shape parameter.gð?(Rtpow(R*R�Rn((s/usr/lib64/python2.6/random.pyR mscC s,d|i�}|tt|� d|�S(sfWeibull distribution.

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

gð?(RR�RP(R*R�R�Rn((s/usr/lib64/python2.6/random.pyR!vsN("t__name__t
__module__t__doc__R4R(R,RR"R#R<R=R?RDtBPFRRRPt _MethodTypet_BuiltinMethodTypeR@RRRRRRRRRRRRR R!(((s/usr/lib64/python2.6/random.pyRGs8       ? 
  J    2 B 5  cB s\eZdZd d�Zd�Zd�Zd�Zd�Zdddd�Z d d�Z
RS(
icC s
|djo[ytttd��d�}Wqhtj
o)ddk}t|i�d�}qhXnt|ttf�pt|�}nt |d�\}}t |d�\}}t |d�\}}t|�dt|�dt|�df|_
d|_ dS( süInitialize internal state from hashable object.

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

If a is not None or an int or long, hash(a) is used instead.

If a is an int or long, a is used directly. Distinct values between
0 and 27814431486575L inclusive are guaranteed to yield distinct
internal states (this guarantee is specific to the default
Wichmann-Hill generator).
iiÿÿÿÿNii<vibvirvi( R(R-R.R/R0R1RcRDthashtdivmodt_seedR)(R*R3R1R+R�Ru((s/usr/lib64/python2.6/random.pyR�s
 0cC sj|i\}}}d|d}d|d}d|d}|||f|_|d|d|d d
S( s3Get the next random number in the range [0.0, 1.0).i«i=vi¬icviªisvg@�Ý@gÀ�Ý@gÀ�Ý@gð?(R�(R*R+R�Ru((s/usr/lib64/python2.6/random.pyR¦s cC s|i|i|ifS(s9Return internal state; can be passed to setstate() later.(R4R�R)(R*((s/usr/lib64/python2.6/random.pyR"ÅscC sM|d}|djo|\}|_|_ntd||if��dS(s:Restore internal state from object returned by getstate().iis?state with version %s passed to Random.setstate() of version %sN(R�R)R7R4(R*R9R:((s/usr/lib64/python2.6/random.pyR#És


cC s¥|djptd��n|i\}}}t|td|d��d}t|td|d��d}t|td|d��d}|||f|_d S(
sÃAct as if n calls to random() were made, but quickly.

n is an int, greater than or equal to 0.

Example use: If you have 2 threads and know that each will
consume no more than a million random numbers, create two Random
objects r1 and r2, then do
r2.setstate(r1.getstate())
r2.jumpahead(1000000)
Then r1 and r2 will use guaranteed-disjoint segments of the full
period.
isn must be >= 0i«i=vi¬icviªisvN(R7R�RDR�(R*RKR+R�Ru((s/usr/lib64/python2.6/random.pyR$Ós
   icC s�t|�t|�jot|�jo
tjnptd��nd|jo
djno9d|jo
djnod|jo
djnptd��nd|jo|jo
|jno}ddk}t|i�d�}t|d@|d?A�}t|d�\}}t|d�\}}t|d�\}}n|pd |pd |pd f|_d|_ dS(
sjSet the Wichmann-Hill seed from (x, y, z).

These must be integers in the range [0, 256).
sseeds must be integersiisseeds must be in range(0, 256)iÿÿÿÿNiÿÿÿii(
RNRDR8R7R1R-R�R�R(R)(R*R+R�RuR1tt((s/usr/lib64/python2.6/random.pyt__whseedés<Z* 'cC s½|djo|i�dSt|�}t|d�\}}t|d�\}}t|d�\}}||dpd}||dpd}||dpd}|i|||�dS(sbSeed from hashable object's hash code.

None or no argument seeds from current time. It is not guaranteed
that objects with distinct hash codes lead to distinct internal
states.

This is obsolete, provided for compatibility with the seed routine
used prior to Python 2.1. Use the .seed() method instead.
Nii(R(t_WichmannHill__whseedR�R�(R*R3R+R�Ru((s/usr/lib64/python2.6/random.pytwhseeds

 N( R�R�R4R(RRR"R#R$R�R�(((s/usr/lib64/python2.6/random.pyR%�s   
cB sFeZdZd�Zd�Zd�ZeZZd�ZeZ Z
RS(sÝ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).
cC s!tttd��d�d?tS(s3Get the next random number in the range [0.0, 1.0).iii(R-R.R/t RECIP_BPF(R*((s/usr/lib64/python2.6/random.pyR!scC sy|djotd��n|t|�jotd��n|dd}ttt|��d�}||d|?S(s>getrandbits(k) -> x. Generates a long int with k random bits.is(number of bits must be greater than zeros#number of bits should be an integeriii(R7RDR8R-R.R/(R*RTtbytesR+((s/usr/lib64/python2.6/random.pyR&%s
cO sdS(s<Stub method. Not used for a system random number generator.N(R((R*targstkwds((s/usr/lib64/python2.6/random.pyt_stub/scO std��dS(sAMethod should not be called for a system random number generator.s*System entropy source does not have state.N(R0(R*R R¡((s/usr/lib64/python2.6/random.pyt_notimplemented4s( R�R�R�RR&R¢RR$R£R"R#(((s/usr/lib64/python2.6/random.pyR's 

 cC sõddk}|GdG|iGHd}d}d}d}|i�}xVt|�D]H} ||�}
||
7}||
|
}t|
|�}t|
|�}qMW|i�} t| |d�GdG||} t||| | �}
d| |
||fGHdS( Niÿÿÿÿttimesgg _ Bg _ Âissec,s!avg %g, stddev %g, min %g, max %g(R1R�trangetmintmaxtroundRz(RKtfuncR R1ttotaltsqsumtsmallesttlargesttt0RZR+tt1tavgtstddev((s/usr/lib64/python2.6/random.pyt_test_generator;s(  
 
 
iÐcC s
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|tdddf�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Õ?( R²RRRRRRRR(tN((s/usr/lib64/python2.6/random.pyt_testQs t__main__(IR�t
__future__RtwarningsRROttypesRR�RR�tmathRRPRRwRR|RR�RR]R RzR
R}R R{R R�tosR
R/tbinasciiRR.t__all__RpRyR�R�R�R�t_randomRR%R'R²R´t_instRRRRRRRRRRRRRRRRR R!R"R#R$R&R�(((s/usr/lib64/python2.6/random.pyt<module>(sh("    
   ÿÿ>�"