156 lines
9.2 KiB
Plaintext
156 lines
9.2 KiB
Plaintext
What is Mersenne Twister (MT)?
|
|
|
|
Mersenne Twister(MT) is a pseudorandom number generating algorithm developped by Makoto Matsumoto and Takuji Nishimura (alphabetical order) in 1996/1997. An improvement on initialization was given on 2002 Jan.
|
|
|
|
MT has the following merits:
|
|
|
|
* It is designed with consideration on the flaws of various existing generators.
|
|
|
|
* The algorithm is coded into a C-source downloadable below.
|
|
|
|
* Far longer period and far higher order of equidistribution than any other implemented generators. (It is proved that the period is 2^19937-1, and 623-dimensional equidistribution property is assured.)
|
|
|
|
* Fast generation. (Although it depends on the system, it is reported that MT is sometimes faster than the standard ANSI-C library in a system with pipeline and cache memory.) (Note added in 2004/3: on 1998, usually MT was much faster than rand(), but the algorithm for rand() has been substituted, and now there are no much difference in speed.)
|
|
|
|
* Efficient use of the memory. (The implemented C-code mt19937.c consumes only 624 words of working area.)
|
|
|
|
-------
|
|
Copyright notice from source code.
|
|
-------
|
|
|
|
A C-program for MT19937, with initialization improved 2002/1/26.
|
|
Coded by Takuji Nishimura and Makoto Matsumoto.
|
|
|
|
Before using, initialize the state by using init_genrand(seed)
|
|
or init_by_array(init_key, key_length).
|
|
|
|
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
|
All rights reserved.
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
modification, are permitted provided that the following conditions
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
notice, this list of conditions and the following disclaimer in the
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
3. The names of its contributors may not be used to endorse or promote
|
|
products derived from this software without specific prior written
|
|
permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
Any feedback is very welcome.
|
|
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
|
|
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
|
|
|
|
-----------
|
|
Note re the period. Using the "bc" program under Linux, we can see that the MT algorithm repeats itself every
|
|
|
|
2^19937-1 =>
|
|
|
|
43154247973881626480552355163379198390539350432267115051652505414033\
|
|
30680137658091130451362931858466554526993825764883531790221733458441\
|
|
39095282691546091680190078753437413962968019201144864809026614143184\
|
|
43276980300066728104984095451588176077132969843762134621790396391341\
|
|
28520562761960051310664637664861599423667548653748024196435029593516\
|
|
86623639090479483476923139783013778207857124190544743328445291831729\
|
|
73242310888265081321626469451077707812282829444775022680488057820028\
|
|
76465939916476626520090056149580034405435369038986289406179287201112\
|
|
08336148084474829135473283672778795656483078469091169458662301697024\
|
|
01260240187028746650033445774570315431292996025187780790119375902863\
|
|
17108414964247337898626750330896137490576634090528957229001603800057\
|
|
16308751913739795550474681543332534749910462481325045163417965514705\
|
|
75481459200859472614836213875557116864445789750886277996487304308450\
|
|
48422342062926651855602433933919084436892101842484467704272766460185\
|
|
29149252772809226975384267702573339289544012054658956103476588553866\
|
|
33902546289962132643282425748035786233580608154696546932563833327670\
|
|
76989943977488852668727852745100296305914696387571542573553447597973\
|
|
44631006783673933274021499309687782967413915145996023742136298987206\
|
|
11431410402147238998090962818915890645693934483330994169632295877995\
|
|
84899336674701487176349480554999616305154122540346529700772114623135\
|
|
57040814930986630657336771911728539870957481678162560842128233801686\
|
|
25334586431254034670806135273543270714478876861861983320777280644806\
|
|
69112571319726258176315131359642954776357636783701934983517846214429\
|
|
49607571909180546251141436663841894338525764522893476524546315357404\
|
|
68786228945885654608562058042468987372436921445092315377698407168198\
|
|
37653823774861419620704154810637936512319281799900662176646716711347\
|
|
16327154817958770053826943934004030617004576911353491878748889234293\
|
|
49340145170571716181125795888889277495426977149914549623916394014822\
|
|
98502533165151143127880200905680845650681887726660983163688388490562\
|
|
18222629339865486456690806721917047404088913498356856624280632311985\
|
|
20436826329415290752972798343429446509992206368781367154091702655772\
|
|
72739132942427752934908260058588476652315095741707783191001616847568\
|
|
56586731928608820701797603072698499873548360423717346602576943472355\
|
|
06301744118874141292438958141549100609752216882230887611431996472330\
|
|
84238013711092744948355781503758684964458574991777286992674421836962\
|
|
11376751010832785437940817490940910430840967741447084363242794768920\
|
|
56200427227961638669149805489831121244676399931955371484012886360748\
|
|
70647956866904857478285521705474011394592962217750257556581106745220\
|
|
14489819919686359653615516812739827407601388996388203187763036687627\
|
|
30157584640042798880691862640268612686180883874939573818125022279689\
|
|
93026744625577395954246983163786300017127922715140603412990218157065\
|
|
96505326007758236773981821290873944498591827499990072235924233345678\
|
|
50671186568839186747704960016277540625331440619019129983789914712515\
|
|
36520033605799350860167880768756856237785709525554130490292719222018\
|
|
41725023571244499118702106426945650613849193734743245039662677990384\
|
|
02386781686809962015879090586549423504699190743519551043722544515740\
|
|
96782908433602593822578073088027385526155197204407562032678062444880\
|
|
34909982321612316877947156134057932495455095280525180101230872587789\
|
|
74115817048245588971438596754408081313438375502988726739523375296641\
|
|
61550140609160798322923982724061478325289247971651993698951918780868\
|
|
12211916417477109024806334910917048274412282811866324459071457871383\
|
|
51234842261380074621914004818152386666043133344875067903582838283562\
|
|
68808323657548206847963954638381953217452250268237244136327576587560\
|
|
91197836532983120667082171493167735643403792897243939867441398918554\
|
|
16612295739356668612658271234696438377122838998040199739078061443675\
|
|
41567107846340467370240377765347817336708484473470205686663615813800\
|
|
36922533822099094664695919301616260979205087421756703065051395428607\
|
|
50806159835357541032147095084278461056701367739794932024202998707731\
|
|
01769258204621070221251412042932253043178961626704777611512359793540\
|
|
41470848709854654265027720573009003338479053342506041195030300017040\
|
|
02887892941404603345869926367501355094942750552591581639980523190679\
|
|
61078499358089668329929768126244231400865703342186809455174050644882\
|
|
90392073167113076951318922965935090186230948105575195603052407871638\
|
|
09219164433754514863301000915916985856242176563624771328981678548246\
|
|
29737624953025136036341276836645617507703197745753491280643317653999\
|
|
59943433081184701471587128161493944212766142282629099500557469810532\
|
|
06610001560295784656616193252269412026831159508949671513845195883217\
|
|
14798274887926185141781997903441728559860772722086667768042609030875\
|
|
48238033454465663056192413083744527546681430154877108777280110860043\
|
|
25892262259413968285283497045571062757701421761565262725153407407625\
|
|
40514993198949445910641466053430537857670986252004986488096114486925\
|
|
86034737143636591940139627063668513892996928694918051725568185082988\
|
|
24954954815796063169517658741420159798754273428026723452481263569157\
|
|
30721315373978104162765371507859850415479728766312294671134815852941\
|
|
88164328250444666927811374744948983850643757875073764963451486253063\
|
|
83391555145690087891955315994462944493235248817599907119135755933382\
|
|
12170619147718505493663221115722292033114850248756330311801880568507\
|
|
35698415805181187107786539535712960143729408652704070219243831672903\
|
|
23231567912289419486240594039074452321678019381871219092155460768444\
|
|
57357855951361330424220615135645751393727093900970723782710124585383\
|
|
76783381610233975868548942306960915402499879074534613119239638529507\
|
|
54758058205625956600817743007191746812655955021747670922460866747744\
|
|
52087560785906233475062709832859348006778945616960249439281376349565\
|
|
75998474857735539909575573132008090408300364464922194099340969487305\
|
|
47494301216165686750735749555882340303989874672975455060957736921559\
|
|
19548081551403591570712993005702711728625284319741331230761788679750\
|
|
67842601954367603059903407084814646072789554954877421407535706212171\
|
|
98252192978869786916734625618430175454903864111585429504569920905636\
|
|
741539030968041471
|
|
|
|
bytes. |