COIN-OR::LEMON - Graph Library

Ticket #105: 2fefbb0c8a28.patch

File 2fefbb0c8a28.patch, 58.2 KB (added by Szabó Mátyás, 10 years ago)
  • lemon/random.cc

    # HG changeset patch
    # User Szabo Matyi <szotyesz@gmail.com>
    # Date 1281089678 -7200
    # Node ID 2fefbb0c8a28f8916fbadd538aa03cc64c7e61cf
    # Parent  24b3f18ed9e2bea99ab482c493c3db769362ecf0
    Ziggurat method added for generating normal variables. (ticket #105)
    
    diff -r 24b3f18ed9e2 -r 2fefbb0c8a28 lemon/random.cc
    a b  
    2626  ///
    2727  /// A global Mersenne Twister random number generator instance.
    2828  Random rnd;
     29
     30  /// \brief Const values
     31  ///
     32  /// Assigning values for the constants used by gaussZiggurat()
     33  const long double Random::ZIGGURAT_LAST = 3.65415288536100877164542972039951576L;
     34  const long double Random::ZIGGURAT_AREA = 0.004928673233974655347361775402336028119L;
     35  const long double Random::ZIGGURAT_K[256] = {0.9343848233974879317193170949916692455, 0.0000000000000000000000000000000000000, 0.7521348930280687524246213713740895751, 0.8523759645978130699803660810752964207, 0.8950104667155143618713804598551490059, 0.9185389646440565642683673609944041631, 0.9334216173562437351780548666273842542, 0.9436712673962500857068891046348752780, 0.9511541202634300022036713224162385409, 0.9568544230590621882139334873043015569, 0.9613398466555956662282521737836561654, 0.9649605353419385137437122801780280423, 0.9679440712828071850390559488986787116, 0.9704447254093692838278864141707656198, 0.9725707453202326909755963824758116575, 0.9744003091155293305514677341053951358, 0.9759912783623027451356212572101422211, 0.9773873891969314958196761363222268067, 0.9786223111921101051894474212876801449, 0.9797223837134003549864735848447041215, 0.9807085063180838892795003664842672834, 0.9815974731966873716248120788673629352, 0.9824029333975924585927503270726708815, 0.9831360937371897352007529341436412744, 0.9838062413625680929589381284595358452, 0.9844211377119530123892405622228223494, 0.9849873193253576278966784472301683623, 0.9855103302158919029156115415616258923, 0.9859949032969659635891043415006211758, 0.9864451034313016862271472965670815233, 0.9868644412471508258358038662493302461, 0.9872559644592855634064928053593573043, 0.9876223317147472997992843421318242521, 0.9879658727429954103769386369549111407, 0.9882886376841037894107391045802180263, 0.9885924377998035292076142060481078287, 0.9888788792734609058610531586962218861, 0.9891493914297551123584128792653079114, 0.9894052504198768393681133446220974375, 0.9896475991999593530206616892155802589, 0.9898774644622064185717771597483648068, 0.9900957710474469907156568747084035253, 0.9903033542655582031357919136805199157, 0.9905009704696422794169269967552537226, 0.9906893061660084209202516789174791078, 0.9908689858911285382619981212980949891, 0.9910405790459506353706656000833177314, 0.9912046058450877969435613195422896993, 0.9913615425117819027841023997509206891, 0.9915118258278775313153858535418546385, 0.9916558571303290272228708551912925983, 0.9917940058312176940721645666345692848, 0.9919266125262598952150970752165679855, 0.9920539917468534200538834204761557299, 0.9921764344024521317642917073515579346, 0.9922942099531692434811387015866564754, 0.9924075683467404497709567415865598904, 0.9925167417491306863213660206200584552, 0.9926219460939817681312563437547671504, 0.9927233824726421330421706677109344597, 0.9928212383835881374925189936576439124, 0.9929156888575519284056081492246678212, 0.9930068974725425432499546598006294328, 0.9930950172711258454942877410220537719, 0.9931801915907666593011137633623989201, 0.9932625548166927962213122122032876603, 0.9933422330655821116079712265851010605, 0.9934193448073723810048694307106728827, 0.9934940014316262976293152120183242329, 0.9935663077641306706436571602030350503, 0.9936363625387534677316131384147719106, 0.9937042588290107899850387094345639406, 0.9937700844432964319229426863633859666, 0.9938339222872893927878783989264123716, 0.9938958506966710911328228727006518534, 0.9939559437429468715342084330267925426, 0.9940142715148695130110472108862883339, 0.9940709003777005751334454152902166963, 0.9941258932123140224552279206582319991, 0.9941793096359417592151026436258322621, 0.9942312062061791322692216057838062738, 0.9942816366097072280193988085308890437, 0.9943306518370453970529046288305885799, 0.9943783003445197209357648408431178232, 0.9944246282045192078444765382992985312, 0.9944696792450097316247147735466991459, 0.9945134951791846874605933282790125789, 0.9945561157260497832252070782478274456, 0.9945975787226662319809935046248467343, 0.9946379202287109065629077328237571182, 0.9946771746239529274188513683172086115, 0.9947153746991929471986422291253565355, 0.9947525517411634255110220591725906976, 0.9947887356118448871105270108966973306, 0.9948239548226140257290487474271917559, 0.9948582366036041114085803269049114050, 0.9948916069686260901297948023363511694, 0.9949240907759696840438705704318230591, 0.9949557117853774011405852385358622438, 0.9949864927114603715406780082101288053, 0.9950164552738031008235599612794694100, 0.9950456202439843525358409889190050137, 0.9950740074897232493657728145186268070, 0.9951016360163431432049457738310611379, 0.9951285240057306945331200051127617964, 0.9951546888529537835195479403379564074, 0.9951801472006892255345549713655524539, 0.9952049149715996717219015268408354612, 0.9952290073987884414965584639437012942, 0.9952524390544512689375282381528486353, 0.9952752238768349686011072857071706387, 0.9952973751956047657964383669747764546, 0.9953189057557144264396052241823354928, 0.9953398277398663031560929832900430376, 0.9953601527896419339030037092221651803, 0.9953798920253778386483850175761165107, 0.9953990560648556147063520463969772615, 0.9954176550408702923546848017750691531, 0.9954356986177361431455654999905922324, 0.9954531960067847008905332371251207411, 0.9954701559809056295924824445467914719, 0.9954865868881772261486649750590393414, 0.9955024966646297533302375877522070470, 0.9955178928461814373173907600259168164, 0.9955327825797838127680083418398043266, 0.9955471726338101375307273647500384792, 0.9955610694077178106857468396283231069, 0.9955744789410130949497756203358518538, 0.9955874069215439521446295990677097642, 0.9955998586931444339860758046966144378, 0.9956118392626518164158678049698359155, 0.9956233533063155114089781783815189589, 0.9956344051756147236865945556422392136, 0.9956449989024998297159963155988231374, 0.9956551382040705319676476080111207311, 0.9956648264867019722521619647355725382, 0.9956740668496281640550998072392830514, 0.9956828620879903153821162792815002520, 0.9956912146953558511767155841359336104, 0.9956991268657121984582105588193143031, 0.9957066004949376585788695710622154259, 0.9957136371817499500225260447393863342, 0.9957202382281312524679078633959436626, 0.9957264046392268087469935476154926669, 0.9957321371227123359128185575635583314, 0.9957374360876236496223767525240453762, 0.9957423016426400067394923931918669345, 0.9957467335938107082477072422421257763, 0.9957507314417124663886236219605738133, 0.9957542943780229138286343565010412738, 0.9957574212814934051776898963655149847, 0.9957601107133019179286868878456753616, 0.9957623609117643853237465741605898428, 0.9957641697863801709729980549558625896, 0.9957655349111846059874780237053496829, 0.9957664535173785340274794342665528187, 0.9957669224852016262337003181418718978, 0.9957669383350128126164214688296826492, 0.9957664972175375028639815506359322228, 0.9957655949032373087467223999261700387, 0.9957642267707537003559785889313145647, 0.9957623877943723939277683718453609486, 0.9957600725304502406923729466383858985, 0.9957572751027409204340205033769870837, 0.9957539891865497916751942439014967294, 0.9957502079916417584709177980759102294, 0.9957459242438189212414925217589005309, 0.9957411301650770182540062583759525396, 0.9957358174522411595195579633927778422, 0.9957299772539720210047168873920471007, 0.9957236001460234086581268337211545401, 0.9957166761046208113602597101797345560, 0.9957091944778181184101047168774683679, 0.9957011439546759438865422304006226194, 0.9956925125320898226750283571373437192, 0.9956832874790797462492626649621569960, 0.9956734552983338921712081246724014194, 0.9956630016847787445836982563203973503, 0.9956519114809248476706317484435727244, 0.9956401686287118884819512031871999452, 0.9956277561175483368751129654481494826, 0.9956146559282090982702448858810834316, 0.9956008489722191240227268168582815808, 0.9955863150263111751173269509765352472, 0.9955710326615013738670867642308689406, 0.9955549791662761450202807801407304181, 0.9955381304633278806771866700052173786, 0.9955204610192132829333028335330776316, 0.9955019437462368257534349514256462822, 0.9954825498957809518683059780901881090, 0.9954622489422131082535091507738625226, 0.9954410084563959253702764201106799640, 0.9954187939677088933529271507558410643, 0.9953955688133555976413487367420004326, 0.9953712939735773845194413629384013703, 0.9953459278912192209411835368694128812, 0.9953194262738929424034826766102422736, 0.9952917418767528524864419874429765764, 0.9952628242636337785852716312851210664, 0.9952326195439962974588418765170482634, 0.9952010700827708903322987410989728569, 0.9951681141797838709976119137881670187, 0.9951336857149729877801099878121939639, 0.9950977137550475359559890725042432892, 0.9950601221166020476652757599384830414, 0.9950208288799365098552483210092672037, 0.9949797458469481829454093341509479294, 0.9949367779354143674972049284044947825, 0.9948918225007499986359943324594951554, 0.9948447685748595927742878633673975934, 0.9947954960099615921853467744963124467, 0.9947438745131848664456421662512876619, 0.9946897625552478696740741457153399240, 0.9946330061335381431835337489419620354, 0.9945734373662973996849821368279935922, 0.9945108728902390284233779827879898240, 0.9944451120285952206846491518813880777, 0.9943759346900740857645330517496707204, 0.9943030989512010011436864381485704015, 0.9942263382646339409194021668384464486, 0.9941453582237755092561456055294676973, 0.9940598327986974355957506115698266622, 0.9939693999391832468851618297381485055, 0.9938736564164405230757445046058561249, 0.9937721517442154136305789879164462945, 0.9936643809806180083572122759757089912, 0.9935497761611747107533552746174739485, 0.9934276960476893663773126024755147700, 0.9932974137912164483693699965956846048, 0.9931581019935842919950909070239250280, 0.9930088145002632514380915523497129226, 0.9928484640534514244889405594839074239, 0.9926757946571649456919454534714149038, 0.9924893471254039949767096798989556623, 0.9922874157550543995815932271921074700, 0.9920679933194187667847439226627082767, 0.9918287005129209497091840746527030027, 0.9915666944323213753050803491634957023, 0.9912785484011166020642043339228142590, 0.9909600920219935933858075689682099665, 0.9906061951002389624967266292412021707, 0.9902104708716601472335879150820460079, 0.9897648607932890390308710965790197360, 0.9892590414228874181382105110962681430, 0.9886795569441160778409317165347916649, 0.9880085157655923756489431303073501986, 0.9872215701917465204510712647424493423, 0.9862846687490864290482996414156381401, 0.9851486053977922265127555451638459273, 0.9837393825978452842500690067790921317, 0.9819400459575832710096712963900578864, 0.9795535510952760959610791031536184233, 0.9762183353489940415327260562554302966, 0.9711859548132215469500362898349345991, 0.9625911412322337204510792186781691145, 0.9439337670790046598883323882335553723};
     36  const long double Random::ZIGGURAT_W[256] = {0.0000000000000000000000000000000000000, .2152418959848816993259761370683725883, .2861745917920725100022016537397011712, .3357375192144252356381953991485326737, .3751213328783805914950934439297150679, .4083891346119911452905580164162148170, .4375184022078716819335150251736012161, .4636343367908822175079229767933660166, .4874439661392360393010732450955664360, .5094233296020918144698232990664082206, .5299097206615581167868101654071696243, .5491517023271651206681005040678395124, .5673382570538187481968115660004037734, .5846167661063793214415876012927114094, .6011046177559926215339006828819496553, .6168969900077514499834684245803310406, .6320722363860611709450001368380460370, .6466957148949938175133894544020029262, .6608225742444197384170741128457007027, .6744998228372938228222914419531452541, .6877678927957885342948586234149493582, .7006618411068150726277974587569366719, .7132122851909759583954372342253491867, .7254461409099996391604214046810695655, .7373872114342955912783028953203031969, .7490566620178152923025768635494649482, .7604734064301080293481121055219705184, .7716544242245680847495728732338933663, .7826150233072331208935580437461365053, .7933690588406232962110942466747657764, .8039291169899712204075395180381795462, .8143066701352152303926948999975811136, .8245122087522921305183106894516239088, .8345553540863821789247268951938139018, .8444449549091539188895824407324268514, .8541891710081638074541801629893975373, .8637955455533088548131785053943591476, .8732710680888607541257627162203026577, .8826222295851655547729366716218178476, .8918550707329415668505867893594969232, .9009752244612218337465478563860209701, .9099879534967184944835295676903646591, .9188981836495906121800344424551277998, .9277105334020001238706771933526831937, .9364293402865751412343496462035937521, .9450586844681654630379075289529035802, .9536024098810860361479443937106453315, .9620641432230405838693517548842371910, .9704473110642244506809678682517822158, .9787551552942246038808242096058843651, .9869907470990624723688077335663660792, .9951569996350909238379128342900822263, 1.003256679544672977063838476902950976, 1.011292417439995739530489041191618720, 1.019266717465484244962537467525868017, 1.027181966035645772350639887939362736, 1.035040439833440875887862746039379827, 1.042844313144148970939980229020162289, 1.050595664590929901514279329073960747, 1.058296483330675084513966896229644540, 1.065948674762122501754284026538320036, 1.073554065792436288292686500464554595, 1.081114409703403838077538136757233297, 1.088631390653979821403993213445027208, 1.096106627852021437094938365415990423, 1.103541679424639718350709546845051632, 1.110938046013575721417560779257848197, 1.118297174119344981546693309349105968, 1.125620459215533391227475593856506348, 1.132909248652533753115898715892140338, 1.140164844368151242664448937938461884, 1.147388505420849058458757243582078009, 1.154581450359927740740669252500178865, 1.161744859445611442407678658730301949, 1.168879876730833138384076802216188050, 1.175987612015452098437940687032686411, 1.183069142682686761029921497512773002, 1.190125515426692069320479795685488633, 1.197157747879441555149951169947665331, 1.204166830144381512972585409228430302, 1.211153726243699183035927701680492616, 1.218119375485481656036492926236469334, 1.225064693756530787096859391988720117, 1.231990574746136091354596183983299844, 1.238897891105687374493975672708950373, 1.245787495548627294596662055366289633, 1.252660221894897227354473865616386891, 1.259516886063714228190559472001645526, 1.266358287018229453775313848849851394, 1.273185207665356364764060323720763167, 1.279998415713817924797308907917921657, 1.286798664493243646316660896517198229, 1.293586693736947753945601406359299250, 1.300363230330837190351929439655933085, 1.307128989030731110178131195502914204, 1.313884673150220489854736808952840104, 1.320630975221056264316363281880976025, 1.327368577627925853644432080219568411, 1.334098153219360045667959181721836753, 1.340820365896404038797740514363137747, 1.347535871180587198226303191916842180, 1.354245316762634995007843766072060747, 1.360949343033283011396528844287145147, 1.367648583597476202662733878746825452, 1.374343665773166259809330405021182465, 1.381035211075855426557023886048994533, 1.387723835689976042816457610158739507, 1.394410150928141013910818209046742403, 1.401094763679250977372468027391928268, 1.407778276846398829890729544114188564, 1.414461289775471190729091975769526480, 1.421144398675309048678328840045533732, 1.427828197030256028046923580264626224, 1.434513276005892200373197821347744084, 1.441200224848723969896483905460819077, 1.447889631280576100338960603208178935, 1.454582081888410275202473614895370547, 1.461278162510275558141634572902431181, 1.467978458618079624962505551018571983, 1.474683555697855570628865196528769502, 1.481394039628187363902263028944763656, 1.488110497057447553013103271226758221, 1.494833515780493555035890159317753956, 1.501563685115463738688173273682447815, 1.508301596281311496171425183785073486, 1.515047842776714566947194255734634622, 1.521803020760998008679228498636570154, 1.528567729437712402628199461442167056, 1.535342571441514138082707130216935165, 1.542128153229001959318075945656599629, 1.548925085474173406375274133330557884, 1.555733983469176375991038619565492327, 1.562555467531044820930627254229273603, 1.569390163415123656042832370955675787, 1.576238702735906320876658002975291299, 1.583101723396029247521107058058590839, 1.589979870024190797461111747861209604, 1.596873794422788175563087978818873197, 1.603784156026094530393066805218239356, 1.610711622369830051160545249046193395, 1.617656869573015532637880619762087078, 1.624620582833034778354059455865974895, 1.631603456934873546471532683464360500, 1.638606196775547730191205373889527388, 1.645629517904782346099997435068183654, 1.652674147083055944977076666279071280, 1.659740822858182552384789747414555991, 1.666830296161665512280717200364772561, 1.673943330926124999231911729230293294, 1.681080704725173871909617303396001687, 1.688243209437195389093695018261920595, 1.695431651934561568299588089192624612, 1.702646854799923151653900407051805019, 1.709889657071301820241745482016101948, 1.717160915017823089741659119609675975, 1.724461502948044912052862397775661375, 1.731792314052963154137933505808924018, 1.739154261285911657262420055628114365, 1.746548278281722412853610819915110057, 1.753975320317671535176286495650269692, 1.761436365318910280539794251593907011, 1.768932414911268589029665159840957316, 1.776464495524522868996124119276482820, 1.784033659549441512971864077807942268, 1.791640986552162594624382322132707950, 1.799287584549720199341728680984234319, 1.806974591350820938703420428388106252, 1.814703175966282671680772343522475608, 1.822474540093885838871898571617809117, 1.830289919682756933756055676984080634, 1.838150586582806633764931304898560234, 1.846057850285185505570580952991447439, 1.854013059760201906750898441184460134, 1.862017605399674118665348784397921373, 1.870072921071266778496337776290840393, 1.878180486292995844684467996043643437, 1.886341828536782820037856553309561647, 1.894558525670704732040885690575956507, 1.902832208550429269452784399230802061, 1.911164563771253338349016119398663784, 1.919557336593188113064282063465455548, 1.928012334052665710328808957510010286, 1.936531428275694700380702197135647039, 1.945116560008678301234686281875392605, 1.953769742384646776692572811817961296, 1.962493064944363052826024381256973049, 1.971288697933659294606356474434684778, 1.980158896900476605540416694815764153, 1.989106007617438123201023091217179220, 1.998132471358419680392214769162857161, 2.007240830560528758913239738198297523, 2.016433734906204123873988577023277316, 2.025713947863854245252399025955270765, 2.035084353729618971413871948694987085, 2.044547965217531455282628792749081810, 2.054107931650652130219475666313815432, 2.063767547811732114341853749078148604, 2.073530263518743034646393248416970639, 2.083399693998304613670792088175896217, 2.093379631138791930166361585961666830, 2.103474055714877305933714304045439376, 2.113687150686653177781935198589004641, 2.124023315689523545420714787478383864, 2.134487182846016909178836604796242306, 2.145083634047888982767999729572052544, 2.155817819876737469119503677197501462, 2.166695180354308542353137142121025875, 2.177721467740293002579164079152502837, 2.188902771626360742839576505604305102, 2.200245546611276427712165173291834914, 2.211756642884160997470500709266730643, 2.223443340092510611365346409716922088, 2.235313384929921110748362199673549689, 2.247375032947389262297952392515658600, 2.259637095173787624597566531167311061, 2.272108990228381861937683717373909732, 2.284800802724492127387834486937222101, 2.297723348902863520079790814230527888, 2.310888250601371758550614355860893781, 2.324308018871132508266119157050788362, 2.337996148796528635433480327093712165, 2.351967227379144761902530751453962862, 2.366237056717290911362148128140184319, 2.380822795172085556506619691319378600, 2.395743119781927356168686681412572635, 2.411018413901119491690349211725036350, 2.426670984937146719863529851633724823, 2.442725318200364223794234919225451407, 2.459208374334705035673859596487016985, 2.476149939670523163756216268162164258, 2.493583041271046768170053296506811199, 2.511544441626694343254607344580082705, 2.530075232159854187716539084126874535, 2.549221550324783104422671371241745008, 2.569035452681843781314262921528080206, 2.589575986708286649808805574507898894, 2.610910518488823671930263694478953824, 2.633116393631582759976309292516891419, 2.656283037576743296802124304559510400, 2.680514643285745101098374611431321955, 2.705933656123062221333700225998573137, 2.732685359044011420043182513046676810, 2.760944005279986201244382392492693736, 2.790921174001927318997779045468291575, 2.822877396826442907534115515646592170, 2.857138730873224588561645268053225413, 2.894121053613412181388100356210102386, 2.934366867208887589959928979567676098, 2.978603279881843165536974212294806626, 3.027837791769593524571714584215605905, 3.083526132002143251877768947617197482, 3.147889289518000685451855194084412255, 3.224575052047801587144019828764774123, 3.320244733839825517532232984442229433, 3.449278298561431270627228213833609902, 3.65415288536100877164542972039951576};
     37  const long double Random::ZIGGURAT_F[256] = {1.0000000000000000000000000000000000000, 0.9771017012676712403958719028623232424, 0.9598790918001063864721355368177321676, 0.9451989534422993663374937058983246011, 0.9320600759592301806794466729781369497, 0.9199915050393467030546919393305939622, 0.9087264400521305371358495130015455433, 0.8980959218983431360736551800130759302, 0.8879846607558330585285782808907007793, 0.8783096558089170642988193057412077302, 0.8690086880368567129171108971602640604, 0.8600336211963312390991730785546578401, 0.8513462584586776908039280506655598262, 0.8429156531122039065210084710145997224, 0.8347162929868831595813455346248784955, 0.8267268339462210784529984605724232172, 0.8189291916037020369838228386506703806, 0.8113078743126559059891034353078868559, 0.8038494831709639496009773773191877211, 0.7965423304229585965483594311891426767, 0.7893761435660241847104790142883389647, 0.7823418326548020550662116086908664085, 0.7754313049811867433194784463929920336, 0.7686373157984858364780082528324492062, 0.7619533468367949113894547563202940275, 0.7553735065070957496342070590320821938, 0.7488924472191564949787484775968092204, 0.7425052963401507068807113506715898166, 0.7362075981268622636931757305608100700, 0.7299952645614758215255965091896199347, 0.7238645334686298099558568695300126609, 0.7178119326307215910159469245719072520, 0.7118342488782480425567969304261862153, 0.7059285013327538895036459074638481203, 0.7000919181365112332161021729855236799, 0.6943219161261163365545772061480828336, 0.6886160830046714148200248682061859818, 0.6829721616449944304920448434538043095, 0.6773880362187731320316303280594883505, 0.6718617198970817742602052688156932366, 0.6663913439087498259637666198780210169, 0.6609751477766628657325425209530869318, 0.6556114705796970066832286408257154584, 0.6502987431108164326531603249706821334, 0.6450354808208220426725418123673773410, 0.6398202774530562825857799795084229508, 0.6346517992876233118646843707436697702, 0.6295287799248363816407275840005433907, 0.6244500155470262044789724836064229104, 0.6194143606058340513025133527180102645, 0.6144207238889135700327208847846716195, 0.6094680649257731554507531906421774849, 0.6045553906974674653472081935922816217, 0.5996817526191249127629564988704503001, 0.5948462437679869802753795814394654305, 0.5900479963328255084942385485827118998, 0.5852861792633709281228355195795012078, 0.5805599961007904740757107099937034809, 0.5758686829723532543477586217623422900, 0.5712115067352527449609555985034667841, 0.5665877632561639981423553976584293905, 0.5619967758145239813449617574870036240, 0.5574378936187656227922528448407143762, 0.5529104904258319475876244518796530006, 0.5484139632552654313379610373516503507, 0.5439477311900258584327227791619384211, 0.5395112342569516744732974688759580948, 0.5351039323804572016488129497472961285, 0.5307253044036615925965440113145664570, 0.5263748471716840536842574837378507176, 0.5220520746723214779337936873507621107, 0.5177565172297559590800880982421515509, 0.5134877207473265929459281759254375940, 0.5092452459957476319634698783366550926, 0.5050286679434679121814066871609388012, 0.5008375751261484265331292897074062726, 0.4966715690524893959145244886445198702, 0.4925302636438681941643300146784247935, 0.4884132847054576548661648116551807269, 0.4843202694266829525196532610668694452, 0.4802508659090464596648476179333112169, 0.4762047327195055479574386158666258633, 0.4721815384677298296661088934559363668, 0.4681809614056932491694053956485013975, 0.4642026890481739948349304598983183669, 0.4602464178128425332979599980625432028, 0.4563118526787161707765572289378718988, 0.4523987068618483115854713832057206732, 0.4485067015072028089453042791947834506, 0.4446355653957391997889252982809417612, 0.4407850346658038213202331816282264154, 0.4369548525479853944015740991225738039, 0.4331447691126521407706575409247572277, 0.4293545410294413390183507375960725108, 0.4255839313380218334216494212980596655, 0.4218327092294957642354651704028331241, 0.4181006498378480253657651568267952288, 0.4143875340408909802233013865022354142, 0.4106931482701880545023740725145679477, 0.4070172843294732249921331357787362750, 0.4033597392211143622217505818114106203, 0.3997203149801970666587667862574420091, 0.3960988185158322493422226007682603344, 0.3924950614593154172943550329127993320, 0.3889088600187885856065422091146134520, 0.3853400348400770917754677108721438572, 0.3817884108733934613128855691064863166, 0.3782538172456189833130542754098154919, 0.3747360871378909068691949800529380184, 0.3712350576682392611715200281044197342, 0.3677505697790323227023560476741926443, 0.3642824681290037835747217704275826107, 0.3608306009896477903421696004242136955, 0.3573948201457802909672866360110215528, 0.3539749808000766118916247973221503421, 0.3505709414814059450181711899416425844, 0.3471825639567935089749480197926644380, 0.3438097131468506091249263796627284939, 0.3404522570445217014218364692867502380, 0.3371100666370059078701992017362235147, 0.3337830158307182743125006155599355143, 0.3304709813791634398917439863337576300, 0.3271738428136013345044559093956939483, 0.3238914823763910661037790970809835935, 0.3206237849569053318347219831788381550, 0.3173706380299135116379656301802145298, 0.3141319315963371042257149150137969375, 0.3109075581262863655784545934204217340, 0.3076974125042919301294638896628141186, 0.3045013919766498539494883665425726720, 0.3013193961008029355532772494456921065, 0.2981513266966853602509128463025881642, 0.2949970877999616939816765064351034949, 0.2918565856170950370053133424694028947, 0.2887297284821827504668106564964507264, 0.2856164268155016026306776830227534292, 0.2825165930837074586599160776763889960, 0.2794301417616377696485754289702792252, 0.2763569892956681140180979309604724634, 0.2732970540685769175867986455435084704, 0.2702502563658752373215579821720440012, 0.2672165183435611472084492990116640378, 0.2641957639972608216355812469044755812, 0.2611879191327208805880859336823771815, 0.2581929113376189498976183354729279854, 0.2552106699546617065595881208714292499, 0.2522411260559419312711185582027550296, 0.2492842124185282851794594110179680921, 0.2463398635012636725186343842410855765, 0.2434080154227501523703385447051059745, 0.2404886059405004281347555040774186867, 0.2375815744312379792995537465514779305, 0.2346868618723299135908745534433770984, 0.2318044108243386154360824112146623762, 0.2289341654146802557791804549323729423, 0.2260760713223802156794807526762002673, 0.2232300757639174689474132960013653255, 0.2203961274801519746702185303164331855, 0.2175741767243311564314467396921265068, 0.2147641752511735991942467387334646121, 0.2119660763070301854024536430888201716, 0.2091798346211250274581030645089436764, 0.2064054063978807434253496463740686701, 0.2036427493103348761882348501248477513, 0.2008918224946565835622617025093816272, 0.1981525865457751389296183427340740325, 0.1954250035141342905233498499079055791, 0.1927090369035891451032298677156060252, 0.1900046516704649820237735487418949535, 0.1873118142238002812992904029558644978, 0.1846304924267992801980612104788851269, 0.1819606555995225745509527451150343444, 0.1793022745228476723468237674033168739, 0.1766553214437350091191745903212084778, 0.1740197700818387699445323760544322875, 0.1713955956375059566925023002060765355, 0.1687827748012115191762697033160173360, 0.1661812857644820656271507361796628237, 0.1635911082323657152922787732142429504, 0.1610122234375110914415996053160838182, 0.1584446141559243183322961483897647837, 0.1558882647244792270745417398779534524, 0.1533431610602628445479485218257873991, 0.1508092906818456942374662426298740681, 0.1482866427325745426398362195485529246, 0.1457752080059940520695037215542625945, 0.1432749789735134314633066445580573952, 0.1407859498144447024560601228462049964, 0.1383081164485507214399345595473512358, 0.1358414765712537356231727148864294658, 0.1333860296916691335326648054936398831, 0.1309417771736443266556051327685099359, 0.1285087222799995377506914024690335750, 0.1260868702201858646913300364384293817, 0.1236762282015965552050678302989515034, 0.1212768054847902172203990344821206923, 0.1188886134429099873963606455746377204, 0.1165116656256108143563094420041850702, 0.1141459778278383596090288211627227434, 0.1117915681638380117019019688952240835, 0.1094484571468116484002607877689163924, 0.1071166677746836469762695694904075342, 0.1047962256224869062132636771341530243, 0.1024871589419350874245980773559000498, 0.1001894987688098176902785901723642609, .09790327903886229337793941854345139619, .09562853671300882712817388905825552895, .09336531191269086898939655518451135022, .09111364806637363962171647855111885873, .08887359206827579735526549684908771360, .08664519445055796477695623771245142363, .08442850957035337702528916382966488976, .08222359581320286756580299940587887463, .08003051581466306225867313237697107629, .07784933670209605361228386481507467369, .07568013035892708091094271510564467330, .07352297371398127248393911537796658007, .07137794905889037995034047389968223216, .06924514439700677443319792791285947552, .06712465382778849663476716661539799339, .06501657797124285421570309139980141924, .06292102443775812203161186315244380034, .06083810834953986763531488318613686733, .05876795292093376194722863739908601592, .05671069010620290378726615237579287355, .05466646132488892178283036215457984715, .05263541827679218399411318677047275808, .05061772386094776543150296936298199141, .04861355321586852525317393032950853925, .04662309490193036961171335909342277236, .04464655225129444886085650469573311648, .04268414491647443729990291378398511573, .04073611065594093316693166021297339090, .03880270740452611649975481767838056610, .03688421568856728834523687871708295328, .03498094146171608536935405701855230735, .03309321945857852240435453453740561483, .03122141719192024889534302789617781979, .02936593975813331575420519429468185389, .02752723566960308396405014623003361369, .02570580400854889811776385578233812357, .02390220330579588266559495012965975942, .02211706270730886604371881311609545179, .02035109623004452043070269183302835037, .01860512127572464577128198432884167242, .01688008315254316846094029254487804863, .01517708830793532697793989561478798963, .01349745060173988012384726956249982588, .01184275785790788897530401612342928335, .01021497143970147143722384241754768889, .008616582769398731937741389370969734505, .007050875471373226983660524389945126659, .005522403299250997232058245553691803960, .004037972593363030821857881542446963095, .002609072746102162951313254924577751483, .001260285930498597564133462215543753420};
     38  const long double Random::ZIGGURAT32_K[256] = {2.006576129185473137644573987221472401e+09, 0.000000000000000000000000000000000000e+00, 1.615197383868006850851634747617192653e+09, 1.830463445922030464343515840163041320e+09, 1.922020342060415360027944216725652939e+09, 1.972547406623961612153379991392395960e+09, 2.004507659962246411997315194529128595e+09, 2.026518615820882595574142873152755670e+09, 2.042587919993541382124988130455408116e+09, 2.054829227035810187404520489745603194e+09, 2.064461600863719180924837378820855905e+09, 2.072236970612139046886045384499109750e+09, 2.078644065258374813408282891617036142e+09, 2.084014179104470643013856920833074648e+09, 2.088579772098372227425130398414759290e+09, 2.092508730431744580223663781390947963e+09, 2.095925310873661364804258192179982520e+09, 2.098923436061822239048934859407800926e+09, 2.101575410853023837509898279371060215e+09, 2.103937798604108780810847284637942720e+09, 2.106055480772589838919969538634971240e+09, 2.107964522608004418332383130440548264e+09, 2.109694235218562887396048418735212426e+09, 2.111268685059210165817066923361490520e+09, 2.112707816126456218915863566310576657e+09, 2.114028295981975228250235518511837528e+09, 2.115244161738559897660185598940817450e+09, 2.116367319073708171246879309423663988e+09, 2.117407931841575694820164964338391757e+09, 2.118374729268389062527625633065214106e+09, 2.119275250370913125072084735705615794e+09, 2.120116040066784909177910476538866575e+09, 2.120902807757051626771116806830530042e+09, 2.121640556497631550323525239160080188e+09, 2.122333688930809477294397782680180116e+09, 2.122986094711535176586041904580814263e+09, 2.123601223092323415703879018358885500e+09, 2.124182143524550444434094373454846993e+09, 2.124731596522030646716946060186542986e+09, 2.125252036564370592876530383730516553e+09, 2.125745668456289397883534964859497217e+09, 2.126214478278344244708680956015081339e+09, 2.126660259844837290826375458159544015e+09, 2.127084637411687675457297699941656427e+09, 2.127489085239968657356541592519832725e+09, 2.127874944511541244183783305294379523e+09, 2.128243438005630430073714795055032266e+09, 2.128595682874611265060642312602369974e+09, 2.128932701800108483571185577822661453e+09, 2.129255432763991061046399051291655720e+09, 2.129564737630805790820862013139076767e+09, 2.129861409706956645948239938812743931e+09, 2.130146180416175095572614411760205808e+09, 2.130419725209494675018589924370852804e+09, 2.130682668810210604066557831839472052e+09, 2.130935589879509796152275958077296436e+09, 2.131179025176067509983294947872498941e+09, 2.131413473272497067090150802304406353e+09, 2.131639397882763318272000515909629378e+09, 2.131857230847248788063902003334473343e+09, 2.132067374815865476831960261209206012e+09, 2.132270205664248567561910211955518024e+09, 2.132466074673497640613610408663254647e+09, 2.132655310500020335749157401251719283e+09, 2.132838220958678508632728915008493179e+09, 2.133015094639551417324664164809266302e+09, 2.133186202376142496279429195546007408e+09, 2.133351798580705898054782910826239035e+09, 2.133512122460506064205735583247004367e+09, 2.133667399127206056142527386454134130e+09, 2.133817840610172838256934867407683320e+09, 2.133963646783260299508432793157749388e+09, 2.134105006213558270771264615006563949e+09, 2.134242096939656729255817994306891323e+09, 2.134375087186150576242054915205035454e+09, 2.134504136020386321952469282548740131e+09, 2.134629393956814468044947128734311784e+09, 2.134751003513749008939269447236309530e+09, 2.134869099726838555463706771726594615e+09, 2.134983810623113760994786241828046213e+09, 2.135095257659085803106982532109026196e+09, 2.135203556126024430239066368110767124e+09, 2.135308815525236150804780081317198338e+09, 2.135411139915888867123078254083918059e+09, 2.135510628237684598547926693117389326e+09, 2.135607374610463384264943448855559380e+09, 2.135701468612625946293614816857075495e+09, 2.135792995540087557110076901951065931e+09, 2.135882036647318460140958197976070736e+09, 2.135968669371885091963100239571771277e+09, 2.136052967543779460753714160403630770e+09, 2.136135001580709772906011594848972502e+09, 2.136214838670422384780585915840426933e+09, 2.136292542941032170182262724562975335e+09, 2.136368175620254360868583463694776366e+09, 2.136441795184354887115496498922791693e+09, 2.136513457497567377579908535612706332e+09, 2.136583215942662527827938564630772318e+09, 2.136651121543298854458143348905943630e+09, 2.136717223078732330083610589464461357e+09, 2.136781567191415521790290349995173716e+09, 2.136844198487974167438585857631712463e+09, 2.136905159634010206058423490061688059e+09, 2.136964491443144760789543362028910108e+09, 2.137022232960682124801558205401332354e+09, 2.137078421542246126607961090227840979e+09, 2.137133092927713086165240859964632125e+09, 2.137186281310740679424951532356927252e+09, 2.137238019404169193125263949595096122e+09, 2.137288338501550681656192224971492169e+09, 2.137337268535042261065471330749813063e+09, 2.137384838129882036018721089718155665e+09, 2.137431074655649813336751078506939641e+09, 2.137476004274499683733920473182904664e+09, 2.137519651986537636831797283637946524e+09, 2.137562041672504509518989246852902802e+09, 2.137603196133912660062879341368845986e+09, 2.137643137130773724520665028006082380e+09, 2.137681885417044570183689194942740973e+09, 2.137719460773909042218991164726703322e+09, 2.137755882041004239781000953391301457e+09, 2.137791167145691797680256050969614820e+09, 2.137825333130466935250958763652829709e+09, 2.137858396178590815880233643181948419e+09, 2.137890371638024993294391531628574027e+09, 2.137921274043740362283868113346839241e+09, 2.137951117138467043446001004769502270e+09, 2.137979913891945977958514525940298124e+09, 2.138007676518737656143886595014702763e+09, 2.138034416494638321687313250274421106e+09, 2.138060144571749152870574078902375762e+09, 2.138084870792239295879538078463139070e+09, 2.138108604500839187465000085047534849e+09, 2.138131354356096330637886571776720016e+09, 2.138153128340421554439184503230195572e+09, 2.138173933768949774860867551917194670e+09, 2.138193777297235357188588207054312376e+09, 2.138212664927798339465457581391622980e+09, 2.138230602015533991943118275278685638e+09, 2.138247593271994438063137986405419652e+09, 2.138263642768547328577529322180881618e+09, 2.138278753938412821698191912731948574e+09, 2.138292929577576358272591781413406765e+09, 2.138306171844570911147392012665779894e+09, 2.138318482259118510780661005958688237e+09, 2.138329861699616882742135450940730172e+09, 2.138340310399452954023669710199920768e+09, 2.138349827942120769969250036206139961e+09, 2.138358413255116986687318841386865965e+09, 2.138366064602582538016305354756988630e+09, 2.138372779576654292638927586859758061e+09, 2.138378555087485484838893121760597787e+09, 2.138383387351888388311516954105886013e+09, 2.138387271880547070275957572553520273e+09, 2.138390203463742073667431948666594814e+09, 2.138392176155522485650223667743713051e+09, 2.138393183256254014319879259742067645e+09, 2.138393217293464360964253200587885186e+09, 2.138392270000899286227153548164348450e+09, 2.138390332295694262797113727436766565e+09, 2.138387394253557416149955798768111823e+09, 2.138383445081849502382497071669496222e+09, 2.138378473090435873964535101223510286e+09, 2.138372465660173646612528093898808542e+09, 2.138365409208884499160286166002187949e+09, 2.138357289154649596990261454920183080e+09, 2.138348089876247898439105049591523089e+09, 2.138337794670542437361075950352021115e+09, 2.138326385706600911020810262574173017e+09, 2.138313843976316858157142046543878514e+09, 2.138300149241275682318548997726194367e+09, 2.138285279975585529636650364644199100e+09, 2.138269213304366308003827637462032940e+09, 2.138251924937560642635315007046785564e+09, 2.138233389098697969461843014888749727e+09, 2.138213578448206897158280905063134688e+09, 2.138192464000830995081864664138727405e+09, 2.138170015036658804491460572814165959e+09, 2.138146199005229574289572569612221876e+09, 2.138120981422121363818189751978437365e+09, 2.138094325757367019288900511452690006e+09, 2.138066193314975300460175977385252742e+09, 2.138036543102758175111689819574250428e+09, 2.138005331691579938324124108691807075e+09, 2.137972513063048119509103351583022347e+09, 2.137938038444558694483529603720901712e+09, 2.137901856130487287416753540479776395e+09, 2.137863911288181938923665309644350281e+09, 2.137824145747259444840926838018249679e+09, 2.137782497770533698327062137409325233e+09, 2.137738901804707946905664739905236313e+09, 2.137693288208739970746496957427663573e+09, 2.137645582957535888499586949183399526e+09, 2.137595707318339909944063780818902724e+09, 2.137543577496858377318108665005050174e+09, 2.137489104249780399754490815193869274e+09, 2.137432192459926663114084866271767352e+09, 2.137372740669763582051990309734413530e+09, 2.137310640568451180572323401823082716e+09, 2.137245776426937265365406882837996339e+09, 2.137178024474852493519012832761029760e+09, 2.137107252212082795141513031910074409e+09, 2.137033317646875680019490018468165832e+09, 2.136956068451149260928178580869548874e+09, 2.136875341022286046684496271878665817e+09, 2.136790959439069810192336616346856176e+09, 2.136702734297517133578579021755728642e+09, 2.136610461410109554304510269453663275e+09, 2.136513920349279089806820133177441469e+09, 2.136412872812855239378722141426344548e+09, 2.136307060785441764326076783440374416e+09, 2.136196204465228461093080432883937713e+09, 2.136079999920397496711909317463261750e+09, 2.135958116432856866870921388709000772e+09, 2.135830193479275852128419490010214828e+09, 2.135695837289994812350611438960433598e+09, 2.135554616914936344831235418282349332e+09, 2.135406059711650047087884306987955661e+09, 2.135249646153430099917295924363418332e+09, 2.135084803834218084830214239221331606e+09, 2.134910900520660230950445331381590262e+09, 2.134727236068816818641407576632202367e+09, 2.134533032981768217161431963196434037e+09, 2.134327425332276301669727989066936713e+09, 2.134109445708477279361224689322958008e+09, 2.133878009755919377881440705522698304e+09, 2.133631897780182903813960213375574759e+09, 2.133369732732727142478759812000492289e+09, 2.133089953717327008901858331751048356e+09, 2.132790783909938467969115019107367342e+09, 2.132470191459180624158614092997944479e+09, 2.132125841496702732052306608335662512e+09, 2.131755036791667486912260906637808341e+09, 2.131354643766000884606358178426321577e+09, 2.130920999450156896451929497182599746e+09, 2.130449793357625042534563109785542644e+09, 2.129935915968586952217103155738690977e+09, 2.129373262194822796148531061154737499e+09, 2.128754473304574447874201853229975315e+09, 2.128070593437806498156782709633863135e+09, 2.127310605585260892854205689821640309e+09, 2.126460794275270472797402484009106380e+09, 2.125503853918584519456429447099273623e+09, 2.124417615091805383396745676560958391e+09, 2.123173181649374126977296006343036323e+09, 2.121732131691359827739578760816967766e+09, 2.120042178939659877229573125117088894e+09, 2.118030198411759721319935682144346477e+09, 2.115590520941763341737654596660684610e+09, 2.112564238022488507960935134929701501e+09, 2.108700192010278576091621558852610741e+09, 2.103575233317437906121696218456900796e+09, 2.096412912039745077440962062672064673e+09, 2.085605957128660166276467205427110671e+09, 2.067148735505880485182895806063984348e+09, 2.027082329597203231225995309720347767e+09};
     39  const long double Random::ZIGGURAT32_W[256] = {1.821088585781359984329725352353679465e-09, 1.002298183668785259714238983897364884e-10, 1.332604288086632778878331434632191451e-10, 1.563399653948960991754175159840531174e-10, 1.746794827647416812810550648391782716e-10, 1.901710101459134115327885450870799061e-10, 2.037353823929427573147765477996325267e-10, 2.158965621101121499705701027034623690e-10, 2.269837847627867196225902275627322722e-10, 2.372187234471048295823034360382744263e-10, 2.467584426801456682322594176079936491e-10, 2.557186886329041424524507038611171409e-10, 2.641874631186103207044357275592180824e-10, 2.722333958867841034389974555432383991e-10, 2.799111501108820650418757846960563513e-10, 2.872650465032791020271686951538226797e-10, 2.943315712670149146323092919020196634e-10, 3.011411590944015502526375718424110367e-10, 3.077194906046705965032214824323080063e-10, 3.140884557912563080071897441303102587e-10, 3.202668823282180979358305332320506524e-10, 3.262710948972101661506097106062512281e-10, 3.321153508457243248799057836762392864e-10, 3.378121838485820401275630130810055752e-10, 3.433726781207581941402996402794044481e-10, 3.488066895016540271707702724027749871e-10, 3.541230254015457021762207641834255889e-10, 3.593295925411247111622117800795907958e-10, 3.644335192196225379098011384467298684e-10, 3.694412572498541773348554254857663915e-10, 3.743586675217241143842877438469694706e-10, 3.791910922784429185058432165522040425e-10, 3.839434165285397928759039796197898290e-10, 3.886201205134308798819439928949875328e-10, 3.932253247635224456384696256054690374e-10, 3.977628289759921876034607007118861857e-10, 4.022361457130447285311196490164655974e-10, 4.066485297348633194927883875650831793e-10, 4.110030036350551782049875108626754270e-10, 4.153023803294364208591109092158716770e-10, 4.195492828549918875780645089158885999e-10, 4.237461618598171018452986924398525918e-10, 4.278953111030117665324520517397335755e-10, 4.319988812329248170697489722411535677e-10, 4.360588920705835992630336648801312585e-10, 4.400772435908044981946738105979299107e-10, 4.440557257649889384153971419253597674e-10, 4.479960274058583117413109889646233975e-10, 4.518997441345008326140082759092479113e-10, 4.557683855733948777806126557317955283e-10, 4.596033818549767473567313205294153117e-10, 4.634060895233838464309986840421716831e-10, 4.671777968968604584521793187143984162e-10, 4.709197289496640393186775227969599538e-10, 4.746330517649111547332897165444996310e-10, 4.783188766034533140951021983937186846e-10, 4.819782636284087206646160902638825737e-10, 4.856122253202595612686035358440886689e-10, 4.892217296133422765481655155652951226e-10, 4.928077027810155807593683228966056113e-10, 4.963710320937086370560731862384453607e-10, 4.999125682713632883004315665292342193e-10, 5.034331277494336655724505599389007790e-10, 5.069334947755466314982591259502932490e-10, 5.104144233521173880877617585547223822e-10, 5.138766390386222481498073538975099274e-10, 5.173208406258261396631415836782419132e-10, 5.207477016930212180813277649456197275e-10, 5.241578720582338940480144665839645797e-10, 5.275519791303825346361374090854732059e-10, 5.309306291715014924595360355165143916e-10, 5.342944084763755362754488566806903174e-10, 5.376438844762406035981463512872247351e-10, 5.409796067725920315867656184035828118e-10, 5.443021081065913375392913828679304821e-10, 5.476119052690696429637915860082425247e-10, 5.509094999556833696690953790735327662e-10, 5.541953795713801259735970737810659395e-10, 5.574700179879747122293110796938023223e-10, 5.607338762583124977408840363977618073e-10, 5.639874032902061860244384508954792367e-10, 5.672310364830687903037727466954241204e-10, 5.704652023299274906035789251274988605e-10, 5.736903169872872956817020587545353197e-10, 5.769067868151177533408513631247684243e-10, 5.801150088890582763574375097482882603e-10, 5.833153714867761485997931405978216291e-10, 5.865082545502643232189861461527857594e-10, 5.896940301257322792780184414469876308e-10, 5.928730627826211809944642352502621566e-10, 5.960457100131632409977302457755066729e-10, 5.992123226138035051136561187529928195e-10, 6.023732450497093396008021227825895194e-10, 6.055288158035078972354202715940461899e-10, 6.086793677093140362660080173532079002e-10, 6.118252282730399118059951853718795376e-10, 6.149667199799121656996958339032605416e-10, 6.181041605900627810714915768334494960e-10, 6.212378634230047677028734151841312437e-10, 6.243681376317534776393978457726248302e-10, 6.274952884673081330146189741403060877e-10, 6.306196175341657339631783617995962258e-10, 6.337414230375005916676152703758073724e-10, 6.368610000226070185484056727713092472e-10, 6.399786406071699502921339147822849755e-10, 6.430946342068982434258907502745252722e-10, 6.462092677550278803410276817897053002e-10, 6.493228259161771339880387340889975443e-10, 6.524355912950127280189041175841951128e-10, 6.555478446401650225234821178550778721e-10, 6.586598650438111232263464367806569114e-10, 6.617719301373274292230274714741547280e-10, 6.648843162833973895976895374546880950e-10, 6.679972987649460324892764079141170187e-10, 6.711111519712600716839003867752938899e-10, 6.742261495816410055099803037979541980e-10, 6.773425647469285294425085256320287231e-10, 6.804606702692227243174028456688072449e-10, 6.835807387801258009683832298119421974e-10, 6.867030429178176310979133455682403888e-10, 6.898278555032738316349047370929101747e-10, 6.929554497159307603785317722832589513e-10, 6.960860992690983950327570360702248090e-10, 6.992200785854196821750017226126267649e-10, 7.023576629726735391521012335014871731e-10, 7.054991288002182575628134681538839936e-10, 7.086447536763725842718167689799192157e-10, 7.117948166270332423170094664404946645e-10, 7.149495982758301021916359338056925531e-10, 7.181093810261236314280312255288472543e-10, 7.212744492451536498848694066193689988e-10, 7.244450894506538175004714259717112076e-10, 7.276215905002527036381080999175429367e-10, 7.308042437839897610446588932330141724e-10, 7.339933434202830870061451583054341846e-10, 7.371891864556955394899039799620354734e-10, 7.403920730688566330173573213914454007e-10, 7.436023067789097202769890328957108771e-10, 7.468201946588673304734131345610317574e-10, 7.500460475542722508127546166284910385e-10, 7.532801803075780778368379081422868553e-10, 7.565229119886806133920603691907482664e-10, 7.597745661320507277136355095842669252e-10, 7.630354709809402610134358396239240598e-10, 7.663059597391552972141641355437150472e-10, 7.695863708309158426602728042188432436e-10, 7.728770481693477148119312466189991636e-10, 7.761783414341814407523335890680423751e-10, 7.794906063592643473445958128340045428e-10, 7.828142050305259748872450103033341872e-10, 7.861495061950736628350312906605753093e-10, 7.894968855821348579132873980294096339e-10, 7.928567262366056217131672459895745940e-10, 7.962294188660112303876064168364284313e-10, 7.996153622017349534396357459992524120e-10, 8.030149633754253909237973381651851232e-10, 8.064286383115514899315002867062222296e-10, 8.098568121371379388786945751067783516e-10, 8.132999196097824782382747251145122838e-10, 8.167584055651312392094575314085323792e-10, 8.202327253850690464208807105170129854e-10, 8.237233454879692704554950631414341354e-10, 8.272307438424429246206414509920789027e-10, 8.307554105061299693639688556119530778e-10, 8.342978481911879939140669638908970873e-10, 8.378585728582554493759426665418941155e-10, 8.414381143407993664515299854744720520e-10, 8.450370170019020660225173195463025984e-10, 8.486558404256989429108326191165526947e-10, 8.522951601458512869458904848359900690e-10, 8.559555684136257664137200009536744258e-10, 8.596376750083572722834446248558570822e-10, 8.633421080932961342627641005369183314e-10, 8.670695151200863153978012429540610756e-10, 8.708205637853903595806741045279616471e-10, 8.745959430434721730111483466083386163e-10, 8.783963641788730491129013492304653157e-10, 8.822225619436729382913958703055775296e-10, 8.860752957642214696168826889390135473e-10, 8.899553510226557675511651297093666089e-10, 8.938635404189993222543420565619392083e-10, 8.978007054201633251871955383149954895e-10, 9.017677178027549294665000388099099696e-10, 9.057654812972425954577914820403757533e-10, 9.097949333417447175330355818467034479e-10, 9.138570469545028418423721479517282220e-10, 9.179528327349849485821819279504403374e-10, 9.220833410045488763323131458907221230e-10, 9.262496640986940465872283518394358554e-10, 9.304529388241561504044638803055776106e-10, 9.346943490954715567236951264544844278e-10, 9.389751287671756576159915779825660018e-10, 9.432965646795249754806975954935284173e-10, 9.476599999375729688507839798438302642e-10, 9.520668374456146058079920675368429217e-10, 9.565185437214803557002337958262373852e-10, 9.610166530179475035247643241091392026e-10, 9.655627717816936944827405961309422925e-10, 9.701585834838005777778067105337494137e-10, 9.748058538598902198329389029935313528e-10, 9.795064366026210160617317557546493486e-10, 9.842622795545743674887042486057638382e-10, 9.890754314556361853241523669466301166e-10, 9.939480493059460582113063916546489606e-10, 9.988824064135034488365052871275937860e-10, 1.003880901204765527099139838105766784e-09, 1.008946066887261598535411591697961965e-09, 1.014080582065644209542853794597323442e-09, 1.019287282427009541000973668696500874e-09, 1.024569173628127401560621882459071890e-09, 1.029929445536882149740355419584890196e-09, 1.035371488003297993617759276980963577e-09, 1.040898908362687151296232919988012727e-09, 1.046515550905554211837217394502674508e-09, 1.052225518586946476529150517269648174e-09, 1.058033197293235856079349162696818695e-09, 1.063943283038443013740626390528502921e-09, 1.069960812527157142795524939070701547e-09, 1.076091197599364332179824987361623803e-09, 1.082340264167232675601783747342782263e-09, 1.088714296369128225107435289348341601e-09, 1.095220086806986835739822476848011306e-09, 1.101864993906249716580914393132638334e-09, 1.108657007651443386686323066856422740e-09, 1.115604825216311661605111640604479534e-09, 1.122717938339859010507515264546981244e-09, 1.130006734718171283539165673606900881e-09, 1.137482616212388604783562440064480251e-09, 1.145158137350671475601317173096824896e-09, 1.153047168473956717064704870880657927e-09, 1.161165089007023148317846141991583257e-09, 1.169529017818483683864868872137778766e-09, 1.178158089592984964939085340186429459e-09, 1.187073788756869316297895913590558342e-09, 1.196300356035048040242056791450865662e-09, 1.205865287551789847113567206313786513e-09, 1.215799953084822591361712522096444770e-09, 1.226140369489594716567690154778254878e-09, 1.236928178731698215381300218663881718e-09, 1.248211899439685559411707618940305874e-09, 1.260048549679602599392505467868676938e-09, 1.272505782099446011727295123528072987e-09, 1.285664739683264028860434141239474404e-09, 1.299623946660164426545509624047340627e-09, 1.314504722518121314949409810661614020e-09, 1.330458899435226148255935529271711322e-09, 1.347680135450052181905182244353975349e-09, 1.366421052817668574843522617392091126e-09, 1.387020237688833459064818086239884899e-09, 1.409946843874451482934744369339014359e-09, 1.435878748075171956735555523828229626e-09, 1.465850178859196922486580533014802381e-09, 1.501559769756999605868020946516084542e-09, 1.546109436936595252497230183539087620e-09, 1.606195372790764677630378032957022033e-09, 1.701597536616497101097102146781755500e-09};
     40
    2941}
  • lemon/random.h

    diff -r 24b3f18ed9e2 -r 2fefbb0c8a28 lemon/random.h
    a b  
    526526
    527527  public:
    528528
     529        ///Constants for the Ziggurat method
     530        static const long double ZIGGURAT_LAST; //3.65415288536100877164542972039951576 - Position of the right end of the last rectangle of the ziggurat.
     531        static const long double ZIGGURAT_AREA; //0.0049286732339746553473617754023360281 - Common area of the rectangles and the base.
     532        static const long double ZIGGURAT_K[], ZIGGURAT_W[], ZIGGURAT_F[]; // Tables needed for the Ziggurat.
     533        static const long double ZIGGURAT32_K[], ZIGGURAT32_W[]; //Faster generating process is available for machines where int is 32 bit.
     534
    529535    ///\name Initialization
    530536    ///
    531537    /// @{
     
    533539    /// \brief Default constructor
    534540    ///
    535541    /// Constructor with constant seeding.
    536     Random() { core.initState(); }
     542    Random() { core.initState(); }
    537543
    538544    /// \brief Constructor with seed
    539545    ///
     
    778784    /// Standard normal (Gauss) distribution.
    779785    /// \note The Cartesian form of the Box-Muller
    780786    /// transformation is used to generate a random normal distribution.
    781     double gauss()
     787    double gaussBoxMuller()
    782788    {
    783789      double V1,V2,S;
    784790      do {
     
    788794      } while(S>=1);
    789795      return std::sqrt(-2*std::log(S)/S)*V1;
    790796    }
     797
    791798    /// Normal (Gauss) distribution with given mean and standard deviation
    792799
    793800    /// Normal (Gauss) distribution with given mean and standard deviation.
    794     /// \sa gauss()
    795     double gauss(double mean,double std_dev)
     801    /// \sa gaussBoxMuller()
     802    double gaussBoxMuller(double mean,double std_dev)
    796803    {
    797       return gauss()*std_dev+mean;
     804      return gaussBoxMuller()*std_dev+mean;
     805    }
     806
     807    /// Old name for backwards compatibility
     808
     809    /// Old name for backwards compatibility, returns gaussBoxMuller().
     810    /// \sa gaussBoxMuller()
     811        double gauss()
     812        {
     813                return gaussBoxMuller();
     814        }
     815
     816    /// Old name for backwards compatibility
     817
     818    /// Old name for backwards compatibility, returns gaussBoxMuller(mean,std_dev).
     819    /// \sa gaussBoxMuller(double mean,double std_dev)
     820        double gauss(double mean,double std_dev)
     821        {
     822                return gaussBoxMuller(mean,std_dev);
     823        }
     824
     825    /// Standard normal (Gauss) distribution
     826
     827    /// Standard normal (Gauss) distribution.
     828    /// \note The Ziggurat Method with 256 rectangles
     829    /// is used to generate a random normal distribution.
     830        double gaussZiggurat()
     831        {         
     832          int h0, i;
     833          double num, x, y, v0, v1, v2;
     834          if(sizeof(int)==4) //For 32 bit integers we have tables for faster computing
     835          {
     836                 for(;;)
     837            {
     838          h0=integer<int>();
     839          i=h0&255;
     840          if (std::abs(h0)<ZIGGURAT32_K[i])  //If it's in the part of the rectangle, that is fully under the graph.
     841            return h0*ZIGGURAT32_W[i];
     842          if(i==0)  // Getting number from the tail with Marsaglia
     843          {
     844            do{
     845              v0=real<double>();
     846              v1=real<double>();
     847              x=-std::log(v0)/ZIGGURAT_LAST;
     848              y=-std::log(v1);
     849            }while(y+y<x*x);
     850            return (h0>0)? ZIGGURAT_LAST+x : -ZIGGURAT_LAST-x;
     851          }
     852          v0=real<double>(); // If it's in the other part of the rectangle.
     853          num=h0*ZIGGURAT32_W[i];
     854          if (ZIGGURAT_F[i]+v0*(ZIGGURAT_F[i-1]-ZIGGURAT_F[i]) < std::exp(-.5*num*num))
     855            return num;
     856                 }
     857          }
     858          else
     859          {
     860        for(;;)
     861            {
     862          h0=integer<int>();
     863          i=h0&255;
     864          v0=real<double>();
     865          num = (h0>0)? v0*ZIGGURAT_W[i] : -v0*ZIGGURAT_W[i];
     866          if (v0<ZIGGURAT_K[i])  //If it's in the part of the rectangle, that is fully under the graph.
     867            return num;
     868          if(i==0)  // Getting number from the tail with Marsaglia
     869          {
     870            do{
     871              v1=real<double>();
     872              v2=real<double>();
     873              x=-std::log(v1)/ZIGGURAT_LAST;
     874              y=-std::log(v2);
     875             }while(y+y<x*x);
     876            return (h0>0)? ZIGGURAT_LAST+x : -ZIGGURAT_LAST-x;
     877          }
     878          v1=real<double>(); // If it's in the other part of the rectangle.
     879          if (ZIGGURAT_F[i]+v1*(ZIGGURAT_F[i-1]-ZIGGURAT_F[i]) < std::exp(-.5*num*num))
     880            return num;
     881            }
     882          }
     883        }
     884
     885    /// Normal (Gauss) distribution with given mean and standard deviation
     886
     887    /// Normal (Gauss) distribution with given mean and standard deviation. Using the Ziggurat method.
     888    /// \sa gaussZiggurat256()
     889    double gaussZiggurat(double mean,double std_dev)
     890    {
     891      return gaussZiggurat()*std_dev+mean;
    798892    }
    799893
    800894    /// Lognormal distribution