Qf{\ ddlmZddlmZmZmZ m Z m Z ddlmZmZmZmZddlmZmZmZddlmZmZm Z!ddl"m#Z$ddl%m&Z'ddl(m)Z*dd l+m,Z-m.Z/dd l0m0Z1dd l"Z2dd l3Z3 dd l4m5Z6gd Z9dedzedz Z:edZ;dedzZdZ?Gdde3jZ@Gdde@ZAe@ZBeBjZCeBjZDeBjZEeBjZFeBjZGeBjZHeBjZIeBjZJeBjZKeBjZLeBjZMeBjZNeBjZOeBjZPeBjZQeBjZReBjZSeBjZTeBjZUeBjZVeBjZWeBjZXeBjZYeBjZZdZ[d dZ\e]e2dre2jeBje_dk(re\y y #e7$r dd l8m5Z6YwxYw)!)warn)logexppieceil)sqrtacoscossin)taufloorisfinite)lgammafabslog2)urandom)Sequence)index) accumulaterepeat)bisectN)sha512)Random SystemRandom betavariatebinomialvariatechoicechoices expovariate gammavariategauss getrandbitsgetstatelognormvariate normalvariate paretovariate randbytesrandintrandom randrangesampleseedsetstateshuffle triangularuniformvonmisesvariateweibullvariateg@@?@5ceZdZ dZd#dZd$fd ZfdZfdZdZdZ d Z d Z d Z d e zfd Ze ZdZdefdZdZdZdZdddZd#dd ddZdZd%dZd&dZd&dZdZd'dZdZdZdZ d Z!d!Z"d(d"Z#xZ$S))rNc6 |j|d|_yN)r- gauss_next)selfxs -/opt/alt/python312/lib64/python3.12/random.py__init__zRandom.__init__~s ! c  |dk(rt|ttfrpt|tr|jdn|}|rt |ddznd}t t|D] }d|z|z dz}|t |z}|dk(rdn|}n|d k(rkt|tttfrPt|tr|j}tj|t|jz}n:t|tdtttttfs td t |E|d|_y) Nr;zlatin-1riCBlr:zOThe only supported seed types are: None, int, float, str, bytes, and bytearray.) isinstancestrbytesdecodeordmaplen bytearrayencodeint from_bytes_sha512digesttypefloat TypeErrorsuperr-r@)rAaversionrBc __class__s rCr-z Random.seeds " az"Random.setstate..s%K]a7m]szstate with version z( passed to Random.setstate() of version )r@rZr.tuple ValueErrorrYr`)rAstater\ internalstaterr^s rCr.zRandom.setstatesH( a<6; 3G]DO G ] + \6; 3G]DO  ' %%K]%K K  G ] +%t||56 6  'Q& 'sA66 B ?BB c"|jSr?)r$rAs rC __getstate__zRandom.__getstate__s}}rEc&|j|yr?)r.)rArhs rC __setstate__zRandom.__setstate__s erEc<|jd|jfS)Nrc)r^r$rks rC __reduce__zRandom.__reduce__s~~r4==?22rEc |jD]T}d|jvryd|jvr|j|_yd|jvsC|j|_yy)N _randbelowr#r*)__mro____dict___randbelow_with_getrandbitsrr_randbelow_without_getrandbits)clskwargsr]s rC__init_subclass__zRandom.__init_subclass__s^ Aqzz) *!$!@!@1::%!$!C!CrEcv |j}|j}||}||k\r||}||k\r|Sr?)r# bit_length)rAnr#krs rCruz"Random._randbelow_with_getrandbitssBE&& LLN N1fAA1frEr;c |j}||k\rtdt||zS||z}||z |z }|}||k\r |}||k\r t||z|zS)NzUnderlying 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*_warn_floor)rAr|maxsizer*remlimitr~s rCrvz%Random._randbelow_without_getrandbitss  < N O&(Q,' 'k3') H5jA5ja'k"Q&&rEcL |j|dzj|dS)Nlittle)r#to_bytesrAr|s rCr(zRandom.randbytess'&A&//8<t |} t|D]#}| ||z }| || |<| ||z d z | |<%| St}|j }t|D]+}| |}||vr | |}||vr ||||| |<-| Scc} w) NzAPopulation must be a sequence. For dicts or sets, use sorted(d).z2The number of counts does not match the populationzCounts must be integersrz)Total of counts must be greater than zero)r}z,Sample larger than population or is negativer4r=r;)rJ _SequencerYrPlist _accumulatergpoprSr,r_bisectrr_ceil_logsetadd)rA populationr}rr| cum_countstotal selectionsrsrresultsetsizepoolrrselected selected_adds rCr,z Random.samplegs h*i0@A A  O  k&12J:!# !UVVNN$EeS) 9::z !LMMU5\Q7JF?IJz!Jvj!45zJ JOO A{{KL LKL L! q5 qE$q1ua.11 1G < #D1Xa!e$ Gq q1uqy/Q uH#<? ? U q)+)A6+vx%/?BGH)+ ++S !'3/KM  $+sC6C;D*;,D'c6 |||z |jzzSr?r*rs rCr1zRandom.uniforms# AET[[]***rEc |j} |dn ||z ||z z }||kDrd|z }d|z }||}}|||z t||zzzS#t$r|cYSwxYw)N?r7)r*ZeroDivisionError_sqrt)rAlowhighmodeur]s rCr0zRandom.triangulars  KKM |$*)DA q5aAaAcCdSjE!a%L000 ! J sA AAc |j} |}d|z }t|dz z|z }||zdz }|t| krn9|||zzS)Nr7rr6)r* NV_MAGICCONSTr)rAmusigmar*u1u2zzzs rCr&zRandom.normalvariatesl BvxBc*R/AQBd2hY AI~rEc |j}|j}d|_|N|tz}tdt d|z z}t ||z}t ||z|_|||zzS)Ngr7)r*r@TWOPIrr_cos_sin)rArrr*rx2pig2rads rCr"z Random.gauss'sy 4 OO 98e#D$cFHn!556ET U"A"4j50DOAI~rEc: t|j||Sr?)_expr&)rArrs rCr%zRandom.lognormvariateMs! D&&r5122rEcD td|jz  |z SNr7)rr*)rAlambds rCr zRandom.expovariateWs' "S4;;=())E11rEc |j}|dkrt|zSd|z }|td||zzz} |}tt|z}|||zz }|} | d||zz ks| d|z t |zkrnId|z } | |zd| |zzz } |} | dkDr|t | ztz} | S|t | z tz} | S)Ngư>rr7)r*rrr_pir_acos)rArkappar*rr~rrdrqfu3thetas rCr2zRandom.vonmisesvariateks  D=68# # %K cAEk" "BS2XAQU ABC!a%K2#'T!W)<#< !G UsQU{ # X 8%(]e+E %(]e+E rEc |dks|dkr td|j}|dkDrtd|zdz }|tz }||z} |}d|cxkrdksnd|z }t |d|z z |z } |t | z} ||z|z} ||| zz| z } | t zd| zz dk\s| t | k\r| |zSz|dk(rt d|z  |zS |} t|ztz }|| z}|dkr |d|z z} nt ||z |z  } |}|dkDr|| |dz zkr | |zS|t | kr | |zSo)Nrz*gammavariate: alpha and beta must be > 0.0r7r5gHz>gP?r8)rgr*rLOG4rr SG_MAGICCONST_e)rAalphabetar*ainvbbbcccrrvrBrr~rrps rCr!zRandom.gammavariates & C<43;IJ J 3; us*+D$,C$,CXb,9,68^sRx)D0DGOGbL#'MA%}$sQw.#5d1gt8Oc\vx((4/ / H%Z2%E8cEk*Aq1uo..AXs7Q53;//t8O48^t8OrEc^ |j|d}|r|||j|dzz Sy)Nr7r)r!)rArrys rCrzRandom.betavariates> 4   eS ) D--dC889 9rEc: d|jz }|d|z zS)Nr7gr)rArrs rCr'zRandom.paretovariates&A $++- TE\""rEcT d|jz }|t| d|z zzSr)r*r)rArrrs rCr3zRandom.weibullvariates3  $++- acDj111rEc |dkr td|dks|dk\r|dk(ry|dk(r|Std|j}|dk(rt||kS|dkDr||j|d|z z S||zdkrFdx}}t d|z }|s|S |t t ||z dzz }||kDr|S|dz }/d }t ||zd|z z}d d |zz} d d| zzd|zz} ||zdz}dd| z z } |} | dz} dt| z } t d| z| z | z| z|z}|dks||kDr@|}| dk\r|| kr|S|sOdd| z z|z}t|d|z z }t |dz|z}t|dzt||z dzz}d }|| | | zz | zz z}t|t|dzz t||z dzz |z zzkr|S)Nrzn must be non-negativerr7z&p must be in the range 0.0 <= p <= 1.0r;rg$@TFgffffff?g= ףp=@gEJYga+e?{Gz?gq= ףp?g@r5gQ?gp= ף@gffffff@) rgr*rr_log2rr_fabsr_lgamma)rAr|rr*rBrr]setup_completespqrr[vrrusr}rrlpqmhs rCrzRandom.binomialvariates q556 6 8qCxCxCxEF F 6&(Q,' ' s7t++AsQw77 7 q54<IAcAgAVE&(Oa/0144q5HQ AES1W%& 4#:  fqj 4!8 + ECK C!G^A HAuQxBa" q(A-12A1uAATza2g "a3.1a=)AEQ;'AENWQUQY%77!% !rBw-!+, ,AAw!ga!en,wq1uqy/AAQUcMQQ5rEr?)Nr:)rr7Nrr7)r7)r;r)%__name__ __module__ __qualname__r`rDr-r$r.rlrnrpryruBPFrvrrr(rr+r)rr/r,rr1r0r&r"r%r r2r!rr'r3r __classcell__)r^s@rCrrns G$LA6B3 (9:3'&-J=%)t'3R&.$/3]~#+tq#+P +12*$L32((TCJ@# 2VrErc4eZdZ dZdZdZdZdZexZZ y)rcT tjtddz tzS)NrGr=)rSrT_urandom RECIP_BPFrks rCr*zSystemRandom.randomus"Ex{+q0I==rEc |dkr td|dzdz}tjt|}||dz|z z S)Nrz#number of bits must be non-negativerGr)rgrSrTr )rAr}numbytesrBs rCr#zSystemRandom.getrandbitsysLH q5BC CEa< NN8H- .X\A%&&rEc t|Sr?)r rs rCr(zSystemRandom.randbytess&{rEc yr?rcrAargskwdss rCr-zSystemRandom.seedsFrEc td)Nz*System entropy source does not have state.)NotImplementedErrorrs rC_notimplementedzSystemRandom._notimplementedsK!"NOOrEN) rrrr*r#r(r-rr$r.rcrErCrrls->' P*)HxrErc6ddlm}m}ddlm}|}t d|Dcgc]}|| }}|} ||} ||| } t |} t|} t| |z dd|d|j|td| | | | fzycc}w)Nr)stdevfmean) perf_counterz.3fz sec, z times z"avg %g, stddev %g, min %g, max %g ) statisticsrrtimerrminmaxprintr)r|funcrrmeanrt0rdatat1xbarrrrs rC_test_generatorr$s/! B!(q!1 2!1AD$K!1D 2 B :D $ E d)C t9D R"WSMs'$-- AB /4T2J JK 3s Bcht|tdt|tdt|tdt|tdt|t dt|t dt|t dt|t dt|t dt|t dt|t d t|t d t|t d t|t d t|t d t|tdt|tdt|tdy)Nrcr)g333333?)dg?)rr7)皙?r7)r(r5)rr7)g?r7)r7r7)r5r7)g4@r7)gi@r7)@r))rr7gUUUUUU?) r$r*r&r%r2rr!r"rr0)Ns rC_testr+sAvr"A}j1A~z2A 3A 3A 4A|[1A|Z0A|Z0A|Z0A|Z0A|Z0A|Z0A|[1A|\2Auj)A{J/Az#89rEfork)after_in_child__main__)i')`warningsrrmathrrrrrrrrrrr rr rr rr rr rrrrrrrrrrrosrr _collections_abcrroperatorrr itertoolsrrrrrr_os_random_sha2rrU ImportErrorhashlib__all__rrrrr rrr_instr-r*r1r0r)rr+r,r/rr&r%r r2r!r"rrr'r3r$r.r#r(r$r+hasattrregister_at_forkrrcrErCr>s.h#LLGGEE@@"2$B$*'  :DJs+  Cyd3i  #I w W^^w |"*6"*X  zz  --    --  OO  -- --## %% ''!!   ''## %% >> >> OO L":0 3C 3 z G}*))*sH H+*H+