Produce Reproducible Seeds for Parallel Random Number Generation

make_rng_seeds(count, seed = FALSE)

Arguments

count

The number of RNG seeds to produce.

seed

A logical specifying whether RNG seeds should be generated or not. (seed = NULL corresponds to seed = FALSE). If a list, then it should be of length count and each element should consist of a valid RNG seed.

Value

Returns a non-named list of count independent L'Ecuyer-CMRG random seeds. If seed is NULL or FALSE, then NULL is returned.

Details

This function generates count independent L'Ecuyer-CMRG random seeds that can be used as .Random.seed for parallel processing. These seeds are produced with help of parallel::nextRNGSubStream() and parallel::nextRNGStream() using a strategy that

seed <- <initial RNG seed>
for (ii in seq_len(count)) {
  seeds[[ii]] <- parallel::nextRNGSubStream(seed)
  seed <- parallel::nextRNGStream(seed)
}

This function forwards the RNG state 1 + count times if seed = TRUE.

Examples

## Set up L'Ecuyer-CMRG random seeds for 100 parallel tasks
## based on .Random.seed in the current R process
seeds <- make_rng_seeds(100L, seed = TRUE)
str(seeds)
#> List of 100
#>  $ : int [1:7] 10407 234545791 1048599139 -339072230 -992253254 -1480979244 1838994959
#>  $ : int [1:7] 10407 551827518 2133301893 -1337210981 582399462 -1661384713 -2103704318
#>  $ : int [1:7] 10407 1036129347 808703659 -953799616 941763477 -718791317 -598882218
#>  $ : int [1:7] 10407 378620982 98396066 -2072252476 892295134 -884469193 1959518326
#>  $ : int [1:7] 10407 -1588841667 -626482507 494373867 1987717847 -933588808 -583602607
#>  $ : int [1:7] 10407 1132159580 568985461 1319782804 1795407688 -1842902250 -259938337
#>  $ : int [1:7] 10407 1401031947 -1720706560 1269781653 1692602988 -1726280605 1282569377
#>  $ : int [1:7] 10407 1944887646 1422647442 1460150106 -1845361982 -1449205459 -1681059650
#>  $ : int [1:7] 10407 1419326909 918107674 437550636 1243296584 -629409091 1228270398
#>  $ : int [1:7] 10407 -1816477670 -839678041 1214345756 -1703228121 438904226 1620927098
#>  $ : int [1:7] 10407 1478156671 -316602239 -572719100 1988160329 -1224673074 1300810463
#>  $ : int [1:7] 10407 -2046817090 -804432212 -639102107 -372610377 -1976590086 -400191893
#>  $ : int [1:7] 10407 915775203 -1639460751 -601966584 49602481 1760893915 1102944160
#>  $ : int [1:7] 10407 821880433 1982078364 -1083878223 -1401468229 -1128531872 892554545
#>  $ : int [1:7] 10407 1865828029 -98999360 118701295 181709652 383381588 -636599092
#>  $ : int [1:7] 10407 -530633599 1274823765 -1510589255 -584472159 649825282 2002359635
#>  $ : int [1:7] 10407 1288531975 -236093717 1010318440 -136533646 1734178154 -1123300945
#>  $ : int [1:7] 10407 261809853 546714845 1595771415 -765900938 166151040 390536785
#>  $ : int [1:7] 10407 2009366902 930030263 -1271716595 -1040802227 -740092487 501215297
#>  $ : int [1:7] 10407 255239851 -647727776 302471080 2109395831 -1974729075 2107404912
#>  $ : int [1:7] 10407 -865038296 -1983949302 -908211989 89256100 -955851687 583294229
#>  $ : int [1:7] 10407 638695512 -722074240 -255476544 -122303467 1939622929 967299096
#>  $ : int [1:7] 10407 1710697167 1475094201 1102029379 446252579 -790602959 350162107
#>  $ : int [1:7] 10407 -2132514628 368192025 -1494950890 991554941 -1650571199 -1079750203
#>  $ : int [1:7] 10407 -505655469 548976841 -1594328339 1778804224 279817333 373972575
#>  $ : int [1:7] 10407 -246098402 496528543 -1277266773 32318347 1795317012 -1066595979
#>  $ : int [1:7] 10407 -326843941 1235088457 518562651 -27273738 2005458633 1731054832
#>  $ : int [1:7] 10407 1215623833 -296253987 292207769 2021327000 73129601 -853439562
#>  $ : int [1:7] 10407 20643305 -1893335955 -1947338433 -199314918 1165222612 430920645
#>  $ : int [1:7] 10407 1034582425 -1669522023 -1817430340 -235886284 -2058714427 -508076143
#>  $ : int [1:7] 10407 -1772669060 178044686 248401156 -1861527405 388202416 1018212115
#>  $ : int [1:7] 10407 1232898189 -1283256373 612849954 487505662 -1685932225 494094271
#>  $ : int [1:7] 10407 -1917780671 1545671768 132311637 -1097941859 502616942 2039867984
#>  $ : int [1:7] 10407 -1191760471 1326509093 142571755 1817336328 -162895611 -1910212180
#>  $ : int [1:7] 10407 -1435750260 21670052 -472085683 -126612012 -983506948 1521013659
#>  $ : int [1:7] 10407 -1797540424 1915097732 1253327836 -326345774 1547625744 -1108226536
#>  $ : int [1:7] 10407 1964891033 997199212 1083963293 1895064032 -119231319 -1331801127
#>  $ : int [1:7] 10407 990746983 -224630928 180003795 -1737956273 -1716465542 1935780683
#>  $ : int [1:7] 10407 -1862603313 1642326364 654238718 1574308717 652383689 -1551443569
#>  $ : int [1:7] 10407 -1697461110 -1523636445 1770773805 266498934 427956849 176458269
#>  $ : int [1:7] 10407 -1080410898 1554819179 119414805 -1721970604 -509349536 -319141223
#>  $ : int [1:7] 10407 -1007089588 1836827440 -1065380191 143421355 475977136 -1473526813
#>  $ : int [1:7] 10407 -1917767803 1467059483 870953123 1445953314 333758707 1299470720
#>  $ : int [1:7] 10407 1775261475 -503919539 -478706400 1516002022 984161885 -369779305
#>  $ : int [1:7] 10407 8415346 587698219 -1060289826 -1455168397 1221460907 1316848136
#>  $ : int [1:7] 10407 -1884923946 -1007364651 1469724646 1636685710 -901214033 128413215
#>  $ : int [1:7] 10407 -1010293164 -1641636478 746697437 664568744 -1807286124 1735137003
#>  $ : int [1:7] 10407 -1986757587 1846064116 739257123 1007872485 -704186000 -1086345365
#>  $ : int [1:7] 10407 762964777 2012103712 452067769 -1745501556 -398487125 -740570257
#>  $ : int [1:7] 10407 -677164487 -1362370124 248749866 -1999386215 -1946985123 -232451098
#>  $ : int [1:7] 10407 1249751520 1899062433 794533842 1689345864 1016780008 1546543545
#>  $ : int [1:7] 10407 531650408 -1507307904 271382781 -1058013972 -1513513510 104147601
#>  $ : int [1:7] 10407 1838425859 1946157141 -185168779 -1404340683 -297827055 1961973035
#>  $ : int [1:7] 10407 -946450809 -435374458 737280580 -1732030630 -1159400116 -1045008430
#>  $ : int [1:7] 10407 -1909994376 1438429565 -1552963991 -1118826573 1290260776 -27138387
#>  $ : int [1:7] 10407 853602797 374663442 -1828256565 -1884270847 -1496679317 -917914049
#>  $ : int [1:7] 10407 -1670249467 -1930958212 2047285517 501050655 -578390264 -407905580
#>  $ : int [1:7] 10407 -921692070 287580576 -2002484073 -709214114 -1880261561 306468840
#>  $ : int [1:7] 10407 -632036846 1042108521 560316762 843416377 2045052135 -1312642473
#>  $ : int [1:7] 10407 1009349595 1377945983 1276038087 295100032 528913652 -1680784712
#>  $ : int [1:7] 10407 847375963 60497883 140287060 69077658 -1714990986 1131847615
#>  $ : int [1:7] 10407 1217547360 -1397058409 717885365 823868371 -1626673526 605462232
#>  $ : int [1:7] 10407 909297924 1513274854 -844201188 -956833107 -170673553 1889694257
#>  $ : int [1:7] 10407 898650960 -838979183 -81592775 -801337603 1519959092 -2078031541
#>  $ : int [1:7] 10407 428343416 -729605420 -226111949 -237535562 -1144819858 -737070043
#>  $ : int [1:7] 10407 -564853181 -740777392 -192955629 1870313227 -964689697 151844601
#>  $ : int [1:7] 10407 -511843847 1815977983 -1190539976 274345713 1660261969 1523191005
#>  $ : int [1:7] 10407 1792855607 -432880496 375765864 656357205 495377715 -1128838164
#>  $ : int [1:7] 10407 155903967 1525390035 -1430807692 1015020059 598878107 1018951035
#>  $ : int [1:7] 10407 -1463644323 1105856188 961958556 -155493338 519029579 -1656467966
#>  $ : int [1:7] 10407 1469604262 -1781533514 490674969 350060880 1639443165 2056214009
#>  $ : int [1:7] 10407 1276320216 1063256387 -1738245084 409255321 144315131 -2101968453
#>  $ : int [1:7] 10407 840314294 1087131290 -1542804697 2117566374 -1454051430 -332661378
#>  $ : int [1:7] 10407 -366056652 -1662356379 1883244343 1377782200 -812682578 877132685
#>  $ : int [1:7] 10407 1207309551 -1071969159 -144294318 209776950 -30089982 -711384483
#>  $ : int [1:7] 10407 -1910248842 705672441 1287183104 -1168112099 -860181869 -542031695
#>  $ : int [1:7] 10407 676793750 759673866 1862529333 557812525 -1369017065 593156373
#>  $ : int [1:7] 10407 2146058124 1056769993 212484905 1593736996 -1452164794 -745632878
#>  $ : int [1:7] 10407 1106045530 1794349204 -759877853 -642933106 -1110659231 347403807
#>  $ : int [1:7] 10407 -850236067 1211067934 -2011513788 1006140514 447021224 -1595444017
#>  $ : int [1:7] 10407 399105717 133354940 -626653278 -1800652062 -759150453 135122196
#>  $ : int [1:7] 10407 1776482936 702859884 781880111 1434191835 362061002 -696280691
#>  $ : int [1:7] 10407 1396102605 -756169483 -1699902754 1838805070 1746297763 2024887455
#>  $ : int [1:7] 10407 1202598385 -1473273085 -196952144 -1686665071 1537854713 -602882121
#>  $ : int [1:7] 10407 1058593358 444178022 1060883287 -2005560621 433905043 1206061586
#>  $ : int [1:7] 10407 -1142577336 -987291571 -1509915036 -1870243767 1342815929 -1442700195
#>  $ : int [1:7] 10407 839841272 -114007902 -131212069 1329752854 662038748 710674345
#>  $ : int [1:7] 10407 -2057069630 -1996478787 442280596 898099034 1704395463 -2080372384
#>  $ : int [1:7] 10407 406887431 1703244408 -1113629504 -1539369961 15656474 -1013644707
#>  $ : int [1:7] 10407 1438336410 -57769016 -1724996946 -832858789 1851173924 648590869
#>  $ : int [1:7] 10407 44255661 1455498604 1484464076 2090998748 -1774408463 -1051000514
#>  $ : int [1:7] 10407 1098326746 222390827 -1288535823 -20032970 -1560780291 -1527781201
#>  $ : int [1:7] 10407 -1146627121 -1043008332 -391394318 1571574987 -1617206559 735244133
#>  $ : int [1:7] 10407 -243673664 198758634 -562481923 -1726170838 -1150975103 -966962855
#>  $ : int [1:7] 10407 -1245580422 1511616179 370844499 -758398415 -788302004 345932837
#>  $ : int [1:7] 10407 132718596 -269077609 1186284256 -700281112 902947186 151611073
#>  $ : int [1:7] 10407 1641337425 989830271 -194847441 -1701587219 -2126246301 -1818757471
#>  $ : int [1:7] 10407 -843707549 -14017078 1452350250 -1957127294 210044167 1589752201
#>  $ : int [1:7] 10407 -400331869 -1003398303 -1363717432 -784442753 1085585152 1246507132
#>   [list output truncated]