On Sat, Jan 31, 2009 at 3:39 PM, Tony Cappellini <cappy2...@gmail.com> wrote:
>
>
> Has anyone ever measured how random (or deterministic) a given sequence of
> numbers generated by rand.randint() are?
>
> Using these arguments for rand.randint(0, 10000000 )
> if a program which calls rand.randint() runs for 10 hours (or a few days),
> will it keep generating a repeatable set of numbers at some point? I'm
> trying to understand the periodicity (or lack of) of the numbers generated
> by rand.randint()

According to the docs
http://docs.python.org/library/random.html
"Python uses the Mersenne Twister as the core generator. It produces
53-bit precision floats and has a period of 2**19937-1."
http://en.wikipedia.org/wiki/Mersenne_twister

2**29937-1 is about 10**13819 which is a pretty big number :-) You
would have to use over 10**13808 numbers per second to start repeating
in 10 hours. So I think you are safe.

Kent

PS The exact value of 2**19937-1 is
431542479738816264805523551633791983905393504322671150516525054140333068013765809113045136293185846655452699382576488353179022173345844139095282691546091680190078753437413962968019201144864809026614143184432769803000667281049840954515881760771329698437621346217903963913412852056276196005131066463766486159942366754865374802419643502959351686623639090479483476923139783013778207857124190544743328445291831729732423108882650813216264694510777078122828294447750226804880578200287646593991647662652009005614958003440543536903898628940617928720111208336148084474829135473283672778795656483078469091169458662301697024012602401870287466500334457745703154312929960251877807901193759028631710841496424733789862675033089613749057663409052895722900160380005716308751913739795550474681543332534749910462481325045163417965514705754814592008594726148362138755571168644457897508862779964873043084504842234206292665185560243393391908443689210184248446770427276646018529149252772809226975384267702573339289
 
54401205465895610347658855386633902546289962132643282425748035786233580608154696546932563833327670769899439774888526687278527451002963059146963875715425735534475979734463100678367393327402149930968778296741391514599602374213629898720611431410402147238998090962818915890645693934483330994169632295877995848993366747014871763494805549996163051541225403465297007721146231355704081493098663065733677191172853987095748167816256084212823380168625334586431254034670806135273543270714478876861861983320777280644806691125713197262581763151313596429547763576367837019349835178462144294960757190918054625114143666384189433852576452289347652454631535740468786228945885654608562058042468987372436921445092315377698407168198376538237748614196207041548106379365123192817999006621766467167113471632715481795877005382694393400403061700457691135349187874888923429349340145170571716181125795888889277495426977149914549623916394014822985025331651511431278802009056808456506818877266609831636883884905621822262
 
93398654864566908067219170474040889134983568566242806323119852043682632941529075297279834342944650999220636878136715409170265577272739132942427752934908260058588476652315095741707783191001616847568565867319286088207017976030726984998735483604237173466025769434723550630174411887414129243895814154910060975221688223088761143199647233084238013711092744948355781503758684964458574991777286992674421836962113767510108327854379408174909409104308409677414470843632427947689205620042722796163866914980548983112124467639993195537148401288636074870647956866904857478285521705474011394592962217750257556581106745220144898199196863596536155168127398274076013889963882031877630366876273015758464004279888069186264026861268618088387493957381812502227968993026744625577395954246983163786300017127922715140603412990218157065965053260077582367739818212908739444985918274999900722359242333456785067118656883918674770496001627754062533144061901912998378991471251536520033605799350860167880768756856237785709
 
52555413049029271922201841725023571244499118702106426945650613849193734743245039662677990384023867816868099620158790905865494235046991907435195510437225445157409678290843360259382257807308802738552615519720440756203267806244488034909982321612316877947156134057932495455095280525180101230872587789741158170482455889714385967544080813134383755029887267395233752966416155014060916079832292398272406147832528924797165199369895191878086812211916417477109024806334910917048274412282811866324459071457871383512348422613800746219140048181523866660431333448750679035828382835626880832365754820684796395463838195321745225026823724413632757658756091197836532983120667082171493167735643403792897243939867441398918554166122957393566686126582712346964383771228389980401997390780614436754156710784634046737024037776534781733670848447347020568666361581380036922533822099094664695919301616260979205087421756703065051395428607508061598353575410321470950842784610567013677397949320242029987077310176925820462
 
10702212514120429322530431789616267047776115123597935404147084870985465426502772057300900333847905334250604119503030001704002887892941404603345869926367501355094942750552591581639980523190679610784993580896683299297681262442314008657033421868094551740506448829039207316711307695131892296593509018623094810557519560305240787163809219164433754514863301000915916985856242176563624771328981678548246297376249530251360363412768366456175077031977457534912806433176539995994343308118470147158712816149394421276614228262909950055746981053206610001560295784656616193252269412026831159508949671513845195883217147982748879261851417819979034417285598607727220866677680426090308754823803345446566305619241308374452754668143015487710877728011086004325892262259413968285283497045571062757701421761565262725153407407625405149931989494459106414660534305378576709862520049864880961144869258603473714363659194013962706366851389299692869491805172556818508298824954954815796063169517658741420159798754273428026
 
72345248126356915730721315373978104162765371507859850415479728766312294671134815852941881643282504446669278113747449489838506437578750737649634514862530638339155514569008789195531599446294449323524881759990711913575593338212170619147718505493663221115722292033114850248756330311801880568507356984158051811871077865395357129601437294086527040702192438316729032323156791228941948624059403907445232167801938187121909215546076844457357855951361330424220615135645751393727093900970723782710124585383767833816102339758685489423069609154024998790745346131192396385295075475805820562595660081774300719174681265595502174767092246086674774452087560785906233475062709832859348006778945616960249439281376349565759984748577355399095755731320080904083003644649221940993409694873054749430121616568675073574955588234030398987467297545506095773692155919548081551403591570712993005702711728625284319741331230761788679750678426019543676030599034070848146460727895549548774214075357062121719825219297886978691
 6734625618430175454903864111585429504569920905636741539030968041471
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to