Wc-v 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 l4m5Z4gd Z8dedzedz Z9edZ:dedzZ;dZGdde3j~Z?Gdde?Z@e?ZAeAjZBeAjZCeAjZDeAjZEeAjZFeAjZGeAjZHeAjZIeAjZJeAjZKeAjZLeAjZMeAjZNeAjZOeAjZPeAjZQeAjZReAjZSeAjZTeAjZUeAjZVeAjZWeAjZXeAjZYdZZd!dZ[e\e2dre2jeAje^d kr e[d Sd S#e6$r dd l7m5Z4YwxYw)")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 ZfdZfdZdZd Z d Z d Z d Z d e zfdZe ZdZdefdZdZdZdZdddZd'dd ddZdZd)dZd*dZd*dZdZdZd Zd!Zd"Z d+d$Z!d%Z"d&Z#xZ$S),rNc: |j|d|_dSN)r- gauss_next)selfxs /usr/lib64/python3.12/random.py__init__zRandom.__init__zs! ! r:c  |dkrt|ttfr~t|tr|jdn|}|rt |ddznd}t t|D] }d|z|z dz}|t |z}|dkrdn|}n|d kryt|tttfrYt|tr|j}tj|t|jz}nEt|tdtttttfs td t!j#|d|_dS) 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.seedsK " a<z"Random.setstate..s"%K%Ka7mmmmm%K%KrEzstate 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%K K  G  ] + + + +*%ggt|||56 6  ' ' 'Q& 's B B3&B..B3c$|jSr?)r$rAs rC __getstate__zRandom.__getstate__s}}rEc*|j|dSr?)r.)rArhs rC __setstate__zRandom.__setstate__s erEc>|jd|jfS)Nrc)r^r$rks rC __reduce__zRandom.__reduce__s~~r4==?22rEc |jD]W}d|jvrdSd|jvr|j|_dSd|jvsE|j|_dSdS)N _randbelowr#r*)__mro____dict___randbelow_with_getrandbitsrr_randbelow_without_getrandbits)clskwargsr]s rC__init_subclass__zRandom.__init_subclass__s   Aqzz)) **!$!@!@1::%%!$!C!C  rEc |j}|j}||}||kr||}||kr|Sr?)r# bit_length)rAnr#krs rCruz"Random._randbelow_with_getrandbitssKE&& LLN KN1ff AA1ffrEr;c |j}||kr#tdt||zS||z}||z |z }|}||kr|}||krt||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 O&&(Q,' 'k3') FH5jjA5jja'k"Q&&rEcP |j|dzj|dS)Nlittle)r#to_bytesrAr|s rCr(zRandom.randbytess'&A&//8<z!Random.sample..s'JJJ!Jvvj!4555JrEz,Sample larger than population or is negativer4r=r;)rJ _SequencerYrPlist _accumulatergpoprSr,r_bisectrr_ceil_logsetadd)rArr}rr|total selectionsrresultsetsizepoolrrselected selected_addrrs ` @@rCr,z Random.sample`s h*i00@A A  O  k&12J:!## !UVVNN$EeS)) 9::zz !LMMU5\Q7JFJJJJJJzJJ JOO A{{{{{{KL LKL L! q55 qE$q1ua.11 1G << #D1X * *Ia!e$ Gq q1uqy/Q uH#<.s-RRRA 55A#6777RrEz4The number of choices must be a keyword argument: k=z2Cannot specify both weights and cumulative weightsz3The number of weights does not match the populationrHz*Total of weights must be greater than zerozTotal of weights must be finiter;c Hg|]}zdS)rrc)rdrrrhirr*rs rCrz"Random.choices..s@+++66+vvx%/?BGHHH+rE) r*rPr_repeatrrrYrJrSrg _isfiniter) rArweightsrr}rrrr|r*rs ` ` @@@@@@rCrzRandom.choicess   O  SRRRRRRRqAQRRR ";w#78  PQ Q { q RS SB#% C<<IJ J>? ? U+++++++++ q)++ +%   !'3//MMM  s C662D(c8 |||z |jzzSr?r*rs rCr1zRandom.uniformsRAET[[]***rErr7c |j} |dn ||z ||z z }||krd|z }d|z }||}}|||z t||zzzS#t$r|cYSwxYw)N?r7)r*ZeroDivisionError_sqrt)rAlowhighmodeur]s rCr0zRandom.triangulars  KKM |$*)DA q55aAaAcCdSjE!a%L000 !   JJJ sA AAc |j} |}d|z }t|dz z|z }||zdz }|t| krn?|||zzS)NTr7rr6)r* NV_MAGICCONSTr)rAmusigmar*u1u2zzzs rCr&zRandom.normalvariatesr BvvxBc*R/AQBd2hY AI~rEc |j}|j}d|_|Y|tz}tdt d|z z}t ||z}t ||z|_|||zzS)Ngr7)r*r@TWOPIrr_cos_sin)rArrr*rx2pig2rads rCr"z Random.gausss} 4 OO 968e#D$cFFHn!556ET U"A"4j50DOAI~rEc@ t|j||Sr?)_expr&)rArrs rCr%zRandom.lognormvariate:s! D&&r5122rEcJ td|jz  |z SNr7)rr*)rAlambds rCr zRandom.expovariateDs' S4;;=())E11rEc |j}|dkrt|zSd|z }|td||zzz} |}tt|z}|||zz }|} | d||zz ks| d|z t |zkrnRd|z } | |zd| |zzz } |} | dkr|t | ztz} | S|t | z tz} | S)Ngư>rr7)r*rrr_pir_acos)rArkappar*rr~rrdrqfu3thetas rCr2zRandom.vonmisesvariateUs  D==668# # %K cAEk" "BS2XAQU ABC!a%K2#'T!W)<#<#< !G UsQU{ # VX 88%(]e+E %(]e+E rEc |dks|dkr td|j}|dkrtd|zdz }|tz }||z} |}d|cxkrdksnd|z }t |d|z z |z } |t | z} ||z|z} ||| zz| z } | t zd| zz dks| t | kr| |zS|dkrt d|z  |zS |} t|ztz }|| z}|dkr |d|z z} nt ||z |z  } |}|dkr|| |dz zkr | |zS|t | kr | |zS{) Nrz*gammavariate: alpha and beta must be > 0.0r7r5TgHz>gP?r8)rgr*rLOG4rr SG_MAGICCONST_e)rAalphabetar*ainvbbbcccrrvrBrr~rrps rCr!zRandom.gammavariates  C<<43;;IJ J 3;; us*+D$,C$,CVXb,,,,9,,,,668^sRx)D0DGOGbL#'MA%}$sQw.#55d1gt8Oc\\vvx((4/ / FH%Z2%E88cEk*AAq1uo..AVXs77Q53;///t8O48^^t8OrEcd |j|d}|r|||j|dzz SdS)Nr7r)r!)rArrys rCrzRandom.betavariatesB *   eS ) 1D--dC889 9srErcJ |dkr td|dks|dkr|dkrdS|dkr|Std|j}|dkrt||kS|dkr||j|d|z z S||zdkrNdx}}t d|z }|s|S |t t ||z dzz }||kr|S|dz }5d }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||krG|}| dkr|| kr|S|sWdd| 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  q5556 6 88qCxxCxxqCxxEF F 66&&(Q,' ' s77t++AsQw77 7 q54<<IAcAgA1VE&&(Oa/0144q55HQ AES1W%& 4#:  fqj 4!8 + ECK C!G^A HAuQxBa" q(A-12A1uuAATzza2gg ">a3.1a=)AEQ;'AENWQUQY%77!% !rBw-!+, ,AAw!ga!en,wq1uqy/AAQUcMQQQ5rEc< d|jz }|d|z zS)Nr7gr)rArrs rCr'zRandom.paretovariate0s&A $++- TE\""rEcZ d|jz }|t| d|z zzSr)r*r)rArrrs rCr3zRandom.weibullvariate7s3  $++- acDj111rEr?)Nr:)rr7Nrr7)r;r)%__name__ __module__ __qualname__r`rDr-r$r.rlrnrpryruBPFrvrrr(rr+r)rr/r,rr1r0r&r"r%r r2r!rrr'r3 __classcell__)r^s@rCrrjst G$$$$$$LAAAAA66666B333 (9:3''''&-J===%)t'3'3'3'3R&&&... $$$/3]]]]]~#+tq#+#+#+#+#+P+++1111(*$$$$L333222"(((T???B8QQQQh### 2 2 2 2 2 2 2rErc6eZdZ dZdZdZdZdZexZZ dS)rc^ tjtddz tzS)NrGr=)rSrT_urandom RECIP_BPFrks rCr*zSystemRandom.randomPs"Ax{+q0I==rEc |dkr td|dzdz}tjt|}||dz|z z S)Nrz#number of bits must be non-negativerGr)rgrSrTr )rAr}numbytesrBs rCr#zSystemRandom.getrandbitsTsNH q55BC CEa< NN8H- .X\A%&&rEc t|Sr?)r rs rCr(zSystemRandom.randbytes\s&{rEc dSr?rcrAargskwdss rCr-zSystemRandom.seedbs FtrEc td)Nz*System entropy source does not have state.)NotImplementedErrorrs rC_notimplementedzSystemRandom._notimplementedfsK!"NOOrEN) rrrr*r#r(r-rr$r.rcrErCrrGsm>>>''' PPP*)HxxxrErcDddlm}m}ddlm}|}fdt d|D}|}||} ||| } t |} t|} t||z dd|djtd| | | | fzdS) Nr)stdevfmean) perf_countercg|]} Srcrc)rdrrfuncs rCrz#_test_generator..s 2 2 2ADD$KKK 2rEz.3fz sec, z times z"avg %g, stddev %g, min %g, max %g ) statisticsrrtimerrminmaxprintr) r|rrrmeanrt0datat1xbarrrrs `` rC_test_generatorr)s////////!!!!!! B 2 2 2 2 2q!1 2 2D B 4:D E$ E d)C t9D R"W A A A A A$-- A A ABB /4T2J JKKKKrE'ct|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|tddS)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_testr1sAvr""A}j11A~z22A 33A 33A 44A|[11A|Z00A|Z00A|Z00A|Z00A|Z00A|Z00A|[11A|\22Auj))A{J//Az#89999rEfork)after_in_child__main__)r*)_warningsrrmathrrrrrrrrrrr rr rr rr rr rrrrrrrrrrrosrr _collections_abcrroperatorrr itertoolsrrrrrr_os_randomrUr ImportErrorhashlib__all__rrrr rrrr_instr-r*r1r0r)rr+r,r/rr&r%r r2r!r"rrr'r3r$r.r#r(r)r1hasattrregister_at_forkrrcrErCrCs*`#"""""LLLLLLLLLLLLLLGGGGGGGGGGGGEEEEEEEEEE@@@@@@@@@@""""""222222$$$$$$BBBBBBBB$$$$$$*))))))    :DDJs+  tCydd3i  #I V 2V 2V 2V 2V 2W^^V 2V 2z"*"*"*"*"*6"*"*X  zz  --    --  OO  -- --## %% ''!!   ''## %% >> >> OO LLL"::::0 73C 333 z EGGGG{***))))))))*sH)) H87H8