Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "xorshift", | ||
"description": "Random number generator using xorshift128+", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Andreas Madsen <amwebdk@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
#xorshift [![Build Status](https://travis-ci.org/AndreasMadsen/xorshift.svg?branch=master)](https://travis-ci.org/AndreasMadsen/xorshift) | ||
> Random number generator using xorshift128+ | ||
> Pseudorandom number generator using [xorshift128+](http://xorshift.di.unimi.it/) | ||
## Installation | ||
```sheel | ||
# npm install xorshift | ||
```bash | ||
npm install xorshift | ||
``` | ||
@@ -27,3 +27,3 @@ | ||
`xorshift.constructor`. In both cases random numbers can be generated using | ||
the two methods, `.random` and `.randomint`. | ||
the two methods `.random` and `.randomint`. | ||
@@ -36,4 +36,4 @@ ```javascript | ||
This method returns a random 64bit double, with its value in the range [0, 1). | ||
That means 0 is inclusive and 1 is exclusive. This is completely similar to | ||
This method returns a random 64-bit double, with its value in the range [0, 1). | ||
That means 0 is inclusive and 1 is exclusive. This is equivalent to | ||
`Math.random()`. | ||
@@ -58,8 +58,8 @@ | ||
This method returns a random 64bit integer. Since JavaScript don't support | ||
64bit integers, the number is represented as an array with two elements in | ||
This method returns a random 64-bit integer. Since JavaScript doesn't support | ||
64-bit integers, the number is represented as an array with two elements in | ||
big-endian order. | ||
This method is useful if high precision is required, the `xorshift.random()` | ||
method won't allow you to get this precision since a 64bit IEEE754 double | ||
method won't allow you to get this precision since a 64-bit IEEE754 double | ||
only contains the 52 most significant bits. | ||
@@ -75,4 +75,4 @@ | ||
This method is used to construct a new random generator, with a specific seed. | ||
This can be useful when testing software where random numbers are involved and | ||
getting consistent results are important. | ||
This is useful when testing software where random numbers are involved and | ||
getting consistent results is important. | ||
@@ -100,5 +100,5 @@ ```javascript | ||
This source also have a | ||
This source also has a | ||
[reference implementation](http://xorshift.di.unimi.it/xorshift128plus.c) | ||
for the xorshift128+ generator. A wrapper around this implementation have been | ||
for the xorshift128+ generator. A wrapper around this implementation has been | ||
created and is used for testing this module. To compile and run it: | ||
@@ -111,4 +111,4 @@ | ||
* `<numbers>` can be any number greater than zero, and it will be the amount | ||
if random numbers in the stdout. The default value is `10`. | ||
* `<numbers>` can be any number greater than zero, and it will be the number | ||
of random numbers written to `stdout`. The default value is `10`. | ||
* `<seed0>` and `<seed1>` forms the 128bit seed that the algorithm uses. Default | ||
@@ -119,3 +119,3 @@ is `[1, 2]`. | ||
**The software is license under "MIT"** | ||
**This software is licensed under "MIT"** | ||
@@ -122,0 +122,0 @@ > Copyright (c) 2014 Andreas Madsen & Emil Bay |
{ | ||
"1-2": [ | ||
"0000000000800045", | ||
"0000000002000104", | ||
"00004000020010C3", | ||
"0000C00002103045", | ||
"0001000801C450C4", | ||
"000148200440334B", | ||
"040118200D8E16DA", | ||
"0C02E8191918B86E", | ||
"1008A12455CA592A", | ||
"1089632414BA78D4", | ||
"91A9641A148E28F6", | ||
"12E81D350FC1ACE2", | ||
"8E096F9BD69EB95F", | ||
"1CA8F8DA5671A4AC", | ||
"3C82486EC937374B", | ||
"2D868C60B39FC6DC", | ||
"38E06AB3E09AAF53", | ||
"37810DB6D2520343", | ||
"14B0DC89C9E6F25A", | ||
"B7E8B8628522813D", | ||
"DE04B55E468DAD7E", | ||
"34CEBB4F598FBAAA", | ||
"260556A0AE6EEE77", | ||
"D98A1BADD16E54D2", | ||
"E339FF97DC7BB4F9", | ||
"B0D7B274C76536B2", | ||
"A18F6B4BE876EF45", | ||
"33334DECFD5FCD75", | ||
"2BA820DC33362436", | ||
"EEF648EFE353814E", | ||
"32E8E32FAAC120AE", | ||
"BC00690A28BD77F9", | ||
"E9427F87F3A18C53", | ||
"C026615E058ED57E", | ||
"7AD955C880820E6B", | ||
"09B370EA339C8E88", | ||
"7319F1749E521815", | ||
"D3F8CE464AECF733", | ||
"0E8DE28A593106FA", | ||
"5B7344420C1EC0F2", | ||
"921203F1F55E7022", | ||
"15B48CFADE6D7D57", | ||
"7AA0E0500BC73DB3", | ||
"EE7F7FFDB4907F5F", | ||
"6BE470D69421DD80", | ||
"7F132F0D8D03CDD0", | ||
"7DECCF8D9A489AC9", | ||
"8820C436D65B2BFE", | ||
"52EA0D25B82C871D", | ||
"E71D077E3CA67206", | ||
"FF0EF4BDBFA51DFA", | ||
"57178C1AF35432F9", | ||
"B6E818C2E2EB7954", | ||
"44421D5F530B29B4", | ||
"6E8F85F1AC970C69", | ||
"59A2785ADF595AEF", | ||
"E5F973A199EA09CA", | ||
"9AE74434B2CD2496", | ||
"E5B27B0A43636040", | ||
"28649D15B69FDEB5", | ||
"0D905D0CF283464F", | ||
"EFF2E2E63100DF1B", | ||
"5BCAEC4E508BD9EB", | ||
"40EF77776C50F7A4", | ||
"BBFC8F9C16579A90", | ||
"37532B741DE05469", | ||
"8D415C2298760355", | ||
"9FFD67BD2E2FC482", | ||
"017087422B205F75", | ||
"7FFC07217DE0769E", | ||
"DD7DDD4439A4C7A5", | ||
"D0C2AEE347B18664", | ||
"9121937FD590BD01", | ||
"31028D3DB47201F6", | ||
"5FF658C94C73AF46", | ||
"D0099EA8FB384FEA", | ||
"EBB8EDCB48D4A221", | ||
"6FC0150ABD68382F", | ||
"BD62E609722164F1", | ||
"CB855E00882723A9", | ||
"F15BDA3033F94088", | ||
"254AF0C383043455", | ||
"0C590E39BA1E6ADB", | ||
"45CCA554A145EF4F", | ||
"0E11133F16AC1370", | ||
"FA9503AE32E7179C", | ||
"4C1041999DD237F5", | ||
"1A4133566B4BD1EA", | ||
"FCDF7A5D59641786", | ||
"2D69865B68E2F9C6", | ||
"A695ED531D30F312", | ||
"0DE7A7011E1D61B2", | ||
"CDC421E2996C00AE", | ||
"404DC66041F5F517", | ||
"81DA8E3A459A73D2", | ||
"119806B643F43D28", | ||
"54CB198610CD0642", | ||
"4254E7F67DBEC1A8", | ||
"A88198FF5E9D7904", | ||
"5CEDAF6F6BB02E6B" | ||
], | ||
"3-4": [ | ||
"00000000018000CB", | ||
"000000000500028A", | ||
"0000C000050031C7", | ||
"0001C000053070CB", | ||
"00020018042CB1CA", | ||
"0002D8500C9878DF", | ||
"0C02B8501EA23FFE", | ||
"1C08183B2E460116", | ||
"2015D34AE435C2C7", | ||
"21931749A20541DD", | ||
"A3F3182DA317715F", | ||
"2574C32A9CEAB73F", | ||
"97925BFF314F6079", | ||
"1D6FE16EF19C46D2", | ||
"852500DF641B7CA1", | ||
"A02C54FB1FF8399C", | ||
"ABAD41914A969D83", | ||
"88D0F616B35978C8", | ||
"26C027D478CF5470", | ||
"A9151605DCC766A6", | ||
"6816558B883338CC", | ||
"CC11D53233DCC866", | ||
"2E372AE6983872DA", | ||
"793CEEBCB5E6AEDF", | ||
"DE399507E31DBA9D", | ||
"53174016D29EA4F2", | ||
"EFAB5902A80564CF", | ||
"B1A9C09F172E5056", | ||
"45020E9351C693E9", | ||
"41E4AB2ADB02D1DB", | ||
"AF07B0DE14F24C84", | ||
"9785988B522E3EC9", | ||
"978860AE27C0E9EC", | ||
"BA29866A31DCA7CE", | ||
"4AECBE4CEB6289C3", | ||
"578D0FCCBF373816", | ||
"B306EE6F3A4FD00E", | ||
"515949A648A11E30", | ||
"E7F37E137EE965A0", | ||
"73AF28A11ECC6A9A", | ||
"9CFE07E104600270", | ||
"1AC3FA82104A7095", | ||
"8F4458B3C2DCACE1", | ||
"35781A44F3C379C1", | ||
"FC626EFC134760B4", | ||
"9C6CA6426B042E59", | ||
"2211E5B3572E77BD", | ||
"A49A8C5A46F60F59", | ||
"ECF233D4B0B664D0", | ||
"55799A09B0460542", | ||
"613F99EC3F0645B5", | ||
"06EDF2B165B0DC5A", | ||
"9ECF0BC4F623712E", | ||
"FCA3F276BBD066F0", | ||
"81521823F6BA6C34", | ||
"480C3B77D636B401", | ||
"14BE686EC8C235AB", | ||
"08497E6FE5223DDF", | ||
"AC8DA547D69A44AA", | ||
"DC4C7DAF18CAD327", | ||
"D3B1E9CAEE03FEA4", | ||
"7FB0EEBC8AC3F53A", | ||
"C6862E220BEA77E5", | ||
"2C7BF093C855EF9A", | ||
"34F052597EA234EC", | ||
"429083F604EA0E81", | ||
"69DF5604FEE26314", | ||
"204B33BC95D8AB20", | ||
"B2EB682D6871F774", | ||
"AC6D198D76C7B83C", | ||
"4795BAA72BB71309", | ||
"54F3CAB8B4490A1A", | ||
"3FC7A66165FB78F0", | ||
"0EFA1C8FA9DA365A", | ||
"006BAC3A8814C38A", | ||
"A9646911E027EC9B", | ||
"39C49FCEA7CD3D93", | ||
"8BF023A3C546ED6E", | ||
"4AF78766ADC6B795", | ||
"6929AE4790429AAC", | ||
"6A8C41F99D2D5147", | ||
"A4AA939E165BC724", | ||
"2FE9B4EDC859BBD7", | ||
"3C47DD8B8737FAC3", | ||
"9D0A070A306C5E27", | ||
"9F0EC6743174C5D2", | ||
"7ADCDBA4759136DD", | ||
"A1E6C9EFF73E83EA", | ||
"D8C35164C84AADFD", | ||
"2ED8BF6C7A49E2E0", | ||
"E972144501B71B47", | ||
"D53C25BCC533AEA2", | ||
"934947302C14561D", | ||
"9D70C46B6329939C", | ||
"82F18FC04F585101", | ||
"BBAE931A8CFBE80A", | ||
"D896E1466C026792", | ||
"B22EA4DAE90BE94B", | ||
"3ABDF60398B56FA9", | ||
"AE17157EB58417A1" | ||
] | ||
"integer": { | ||
"1-2": [ | ||
"0000000000800045", | ||
"0000000002000104", | ||
"00004000020010C3", | ||
"0000C00002103045", | ||
"0001000801C450C4", | ||
"000148200440334B", | ||
"040118200D8E16DA", | ||
"0C02E8191918B86E", | ||
"1008A12455CA592A", | ||
"1089632414BA78D4", | ||
"91A9641A148E28F6", | ||
"12E81D350FC1ACE2", | ||
"8E096F9BD69EB95F", | ||
"1CA8F8DA5671A4AC", | ||
"3C82486EC937374B", | ||
"2D868C60B39FC6DC", | ||
"38E06AB3E09AAF53", | ||
"37810DB6D2520343", | ||
"14B0DC89C9E6F25A", | ||
"B7E8B8628522813D", | ||
"DE04B55E468DAD7E", | ||
"34CEBB4F598FBAAA", | ||
"260556A0AE6EEE77", | ||
"D98A1BADD16E54D2", | ||
"E339FF97DC7BB4F9", | ||
"B0D7B274C76536B2", | ||
"A18F6B4BE876EF45", | ||
"33334DECFD5FCD75", | ||
"2BA820DC33362436", | ||
"EEF648EFE353814E", | ||
"32E8E32FAAC120AE", | ||
"BC00690A28BD77F9", | ||
"E9427F87F3A18C53", | ||
"C026615E058ED57E", | ||
"7AD955C880820E6B", | ||
"09B370EA339C8E88", | ||
"7319F1749E521815", | ||
"D3F8CE464AECF733", | ||
"0E8DE28A593106FA", | ||
"5B7344420C1EC0F2", | ||
"921203F1F55E7022", | ||
"15B48CFADE6D7D57", | ||
"7AA0E0500BC73DB3", | ||
"EE7F7FFDB4907F5F", | ||
"6BE470D69421DD80", | ||
"7F132F0D8D03CDD0", | ||
"7DECCF8D9A489AC9", | ||
"8820C436D65B2BFE", | ||
"52EA0D25B82C871D", | ||
"E71D077E3CA67206", | ||
"FF0EF4BDBFA51DFA", | ||
"57178C1AF35432F9", | ||
"B6E818C2E2EB7954", | ||
"44421D5F530B29B4", | ||
"6E8F85F1AC970C69", | ||
"59A2785ADF595AEF", | ||
"E5F973A199EA09CA", | ||
"9AE74434B2CD2496", | ||
"E5B27B0A43636040", | ||
"28649D15B69FDEB5", | ||
"0D905D0CF283464F", | ||
"EFF2E2E63100DF1B", | ||
"5BCAEC4E508BD9EB", | ||
"40EF77776C50F7A4", | ||
"BBFC8F9C16579A90", | ||
"37532B741DE05469", | ||
"8D415C2298760355", | ||
"9FFD67BD2E2FC482", | ||
"017087422B205F75", | ||
"7FFC07217DE0769E", | ||
"DD7DDD4439A4C7A5", | ||
"D0C2AEE347B18664", | ||
"9121937FD590BD01", | ||
"31028D3DB47201F6", | ||
"5FF658C94C73AF46", | ||
"D0099EA8FB384FEA", | ||
"EBB8EDCB48D4A221", | ||
"6FC0150ABD68382F", | ||
"BD62E609722164F1", | ||
"CB855E00882723A9", | ||
"F15BDA3033F94088", | ||
"254AF0C383043455", | ||
"0C590E39BA1E6ADB", | ||
"45CCA554A145EF4F", | ||
"0E11133F16AC1370", | ||
"FA9503AE32E7179C", | ||
"4C1041999DD237F5", | ||
"1A4133566B4BD1EA", | ||
"FCDF7A5D59641786", | ||
"2D69865B68E2F9C6", | ||
"A695ED531D30F312", | ||
"0DE7A7011E1D61B2", | ||
"CDC421E2996C00AE", | ||
"404DC66041F5F517", | ||
"81DA8E3A459A73D2", | ||
"119806B643F43D28", | ||
"54CB198610CD0642", | ||
"4254E7F67DBEC1A8", | ||
"A88198FF5E9D7904", | ||
"5CEDAF6F6BB02E6B" | ||
], | ||
"3-4": [ | ||
"00000000018000CB", | ||
"000000000500028A", | ||
"0000C000050031C7", | ||
"0001C000053070CB", | ||
"00020018042CB1CA", | ||
"0002D8500C9878DF", | ||
"0C02B8501EA23FFE", | ||
"1C08183B2E460116", | ||
"2015D34AE435C2C7", | ||
"21931749A20541DD", | ||
"A3F3182DA317715F", | ||
"2574C32A9CEAB73F", | ||
"97925BFF314F6079", | ||
"1D6FE16EF19C46D2", | ||
"852500DF641B7CA1", | ||
"A02C54FB1FF8399C", | ||
"ABAD41914A969D83", | ||
"88D0F616B35978C8", | ||
"26C027D478CF5470", | ||
"A9151605DCC766A6", | ||
"6816558B883338CC", | ||
"CC11D53233DCC866", | ||
"2E372AE6983872DA", | ||
"793CEEBCB5E6AEDF", | ||
"DE399507E31DBA9D", | ||
"53174016D29EA4F2", | ||
"EFAB5902A80564CF", | ||
"B1A9C09F172E5056", | ||
"45020E9351C693E9", | ||
"41E4AB2ADB02D1DB", | ||
"AF07B0DE14F24C84", | ||
"9785988B522E3EC9", | ||
"978860AE27C0E9EC", | ||
"BA29866A31DCA7CE", | ||
"4AECBE4CEB6289C3", | ||
"578D0FCCBF373816", | ||
"B306EE6F3A4FD00E", | ||
"515949A648A11E30", | ||
"E7F37E137EE965A0", | ||
"73AF28A11ECC6A9A", | ||
"9CFE07E104600270", | ||
"1AC3FA82104A7095", | ||
"8F4458B3C2DCACE1", | ||
"35781A44F3C379C1", | ||
"FC626EFC134760B4", | ||
"9C6CA6426B042E59", | ||
"2211E5B3572E77BD", | ||
"A49A8C5A46F60F59", | ||
"ECF233D4B0B664D0", | ||
"55799A09B0460542", | ||
"613F99EC3F0645B5", | ||
"06EDF2B165B0DC5A", | ||
"9ECF0BC4F623712E", | ||
"FCA3F276BBD066F0", | ||
"81521823F6BA6C34", | ||
"480C3B77D636B401", | ||
"14BE686EC8C235AB", | ||
"08497E6FE5223DDF", | ||
"AC8DA547D69A44AA", | ||
"DC4C7DAF18CAD327", | ||
"D3B1E9CAEE03FEA4", | ||
"7FB0EEBC8AC3F53A", | ||
"C6862E220BEA77E5", | ||
"2C7BF093C855EF9A", | ||
"34F052597EA234EC", | ||
"429083F604EA0E81", | ||
"69DF5604FEE26314", | ||
"204B33BC95D8AB20", | ||
"B2EB682D6871F774", | ||
"AC6D198D76C7B83C", | ||
"4795BAA72BB71309", | ||
"54F3CAB8B4490A1A", | ||
"3FC7A66165FB78F0", | ||
"0EFA1C8FA9DA365A", | ||
"006BAC3A8814C38A", | ||
"A9646911E027EC9B", | ||
"39C49FCEA7CD3D93", | ||
"8BF023A3C546ED6E", | ||
"4AF78766ADC6B795", | ||
"6929AE4790429AAC", | ||
"6A8C41F99D2D5147", | ||
"A4AA939E165BC724", | ||
"2FE9B4EDC859BBD7", | ||
"3C47DD8B8737FAC3", | ||
"9D0A070A306C5E27", | ||
"9F0EC6743174C5D2", | ||
"7ADCDBA4759136DD", | ||
"A1E6C9EFF73E83EA", | ||
"D8C35164C84AADFD", | ||
"2ED8BF6C7A49E2E0", | ||
"E972144501B71B47", | ||
"D53C25BCC533AEA2", | ||
"934947302C14561D", | ||
"9D70C46B6329939C", | ||
"82F18FC04F585101", | ||
"BBAE931A8CFBE80A", | ||
"D896E1466C026792", | ||
"B22EA4DAE90BE94B", | ||
"3ABDF60398B56FA9", | ||
"AE17157EB58417A1" | ||
] | ||
}, | ||
"double": { | ||
"1-2": [ | ||
"4.54747350886464118958e-13", | ||
"1.81898940354585647583e-12", | ||
"3.81469908483644815078e-06", | ||
"1.14440936733739562214e-05", | ||
"1.52606533145860367995e-05", | ||
"1.95577779329436651778e-05", | ||
"1.56416967634458448089e-02", | ||
"4.69193516993040571350e-02", | ||
"6.26316751202378174668e-02", | ||
"6.45963633621506883031e-02", | ||
"5.68990951888331597530e-01", | ||
"7.38542799515529146959e-02", | ||
"5.54831481501077972140e-01", | ||
"1.11953309350104834863e-01", | ||
"2.36362959906924130493e-01", | ||
"1.77834294899752443087e-01", | ||
"2.22174328723307556999e-01", | ||
"2.16812951215906934976e-01", | ||
"8.08236919782776563892e-02", | ||
"7.18394779255627113912e-01", | ||
"8.67259345547202631366e-01", | ||
"2.06279475090524355707e-01", | ||
"1.48518957356312153451e-01", | ||
"8.49763612686211589065e-01", | ||
"8.87603735518935677007e-01", | ||
"6.90791276464911119248e-01", | ||
"6.31094652206651840487e-01", | ||
"2.00001592978309439275e-01", | ||
"1.70534185180450936770e-01", | ||
"9.33445509497074610294e-01", | ||
"1.98866080415204482534e-01", | ||
"7.34381260853060657823e-01", | ||
"9.11170931521729343672e-01", | ||
"7.50585637526053561785e-01", | ||
"4.79878770304374313582e-01", | ||
"3.78943034917131882366e-02", | ||
"4.49614611598299740436e-01", | ||
"8.28015224610613165268e-01", | ||
"5.68524921192796739433e-02", | ||
"3.57227579235877890085e-01", | ||
"5.70587393352406158087e-01", | ||
"8.47862350914760920517e-02", | ||
"4.79017276327593277685e-01", | ||
"9.31632995071199010439e-01", | ||
"4.21454479586947927672e-01", | ||
"4.96386471565542386486e-01", | ||
"4.91894695349659238914e-01", | ||
"5.31749976528186341085e-01", | ||
"3.23883840283246016156e-01", | ||
"9.02786701507148015011e-01", | ||
"9.96321960759491753734e-01", | ||
"3.40203053073609096302e-01", | ||
"7.14479014949501722853e-01", | ||
"2.66633830807262217633e-01", | ||
"4.31877490522847296006e-01", | ||
"3.50135347543390595959e-01", | ||
"8.98337580636429322567e-01", | ||
"6.05091345659094503873e-01", | ||
"8.97254648214028005526e-01", | ||
"1.57785241891019056837e-01", | ||
"5.29840618714958466740e-02", | ||
"9.37299901198460405638e-01", | ||
"3.58565110320838487112e-01", | ||
"2.53653971344025341850e-01", | ||
"7.34322524649853258794e-01", | ||
"2.16112819527439770084e-01", | ||
"5.51778562971286135053e-01", | ||
"6.24960406958222414175e-01", | ||
"5.62329640809022812675e-03", | ||
"4.99939389874158868210e-01", | ||
"8.65201787144218137371e-01", | ||
"8.15470629204076757901e-01", | ||
"5.66918581685572631201e-01", | ||
"1.91445186199821648643e-01", | ||
"3.74852704186606988657e-01", | ||
"8.12646785979468155858e-01", | ||
"9.20790540819171443587e-01", | ||
"4.36524691698111366733e-01", | ||
"7.39790322595700100550e-01", | ||
"7.95003771905751666083e-01", | ||
"9.42807804840389174217e-01", | ||
"1.45674751026505289175e-01", | ||
"4.82338801322099719471e-02", | ||
"2.72653897439588899232e-01", | ||
"5.49480465912639548520e-02", | ||
"9.78836278943074455938e-01", | ||
"2.97123050693536283617e-01", | ||
"1.02557381246966672350e-01", | ||
"9.87785003462150479336e-01", | ||
"1.77391431156944667791e-01", | ||
"6.50725205222616898126e-01", | ||
"5.43159845093348359057e-02", | ||
"8.03773992368789436114e-01", | ||
"2.51186750889210719251e-01", | ||
"5.07241143442664244034e-01", | ||
"6.87259860023494706383e-02", | ||
"3.31224055510393355917e-01", | ||
"2.59108064344895971942e-01", | ||
"6.58227503152934323438e-01", | ||
"3.63001789762791293725e-01" | ||
], | ||
"3-4": [ | ||
"1.36424205265939235687e-12", | ||
"4.54747350886464118958e-12", | ||
"1.14440963450146426794e-05", | ||
"2.67028855789330776815e-05", | ||
"3.05231698571883924842e-05", | ||
"4.34108193034798972576e-05", | ||
"4.69165034870762109875e-02", | ||
"1.09498514603068031192e-01", | ||
"1.25333028587383488173e-01", | ||
"1.31150680043011114151e-01", | ||
"6.40428076879371976915e-01", | ||
"1.46312902358583185602e-01", | ||
"5.92077016642460929319e-01", | ||
"1.14988412462126099456e-01", | ||
"5.20095877207592982572e-01", | ||
"6.25676451978478764815e-01", | ||
"6.70612428638003743586e-01", | ||
"5.34438496153006203926e-01", | ||
"1.51369561551118581022e-01", | ||
"6.60477997237447933543e-01", | ||
"4.06590792241513510064e-01", | ||
"7.97147106892100332232e-01", | ||
"1.80529290483009807744e-01", | ||
"4.73586007186805435509e-01", | ||
"8.68066133905009307270e-01", | ||
"3.24573522159534721965e-01", | ||
"9.36208308361548002807e-01", | ||
"6.93996466484514629158e-01", | ||
"2.69562636343630979141e-01", | ||
"2.57395456278582956955e-01", | ||
"6.83711103648371398833e-01", | ||
"5.91882261289520483771e-01", | ||
"5.91924707907085956293e-01", | ||
"7.27196122099359687496e-01", | ||
"2.92674917010467439127e-01", | ||
"3.41996180998844989674e-01", | ||
"6.99324514537067232212e-01", | ||
"3.17768672081573777533e-01", | ||
"9.06059150466636875620e-01", | ||
"4.51891459785473070809e-01", | ||
"6.13251202045262289175e-01", | ||
"1.04552895311181393012e-01", | ||
"5.59636634718901238017e-01", | ||
"2.08863870462449474630e-01", | ||
"9.85876976529906468016e-01", | ||
"6.11032859053935784033e-01", | ||
"1.33085590633692296691e-01", | ||
"6.42983219185190080225e-01", | ||
"9.25570716310823993211e-01", | ||
"3.33886744847653460511e-01", | ||
"3.79876728226940407751e-01", | ||
"2.70682986353592003326e-02", | ||
"6.20346770845697781382e-01", | ||
"9.86876634586054901632e-01", | ||
"5.05158909588069970908e-01", | ||
"2.81436650044464498066e-01", | ||
"8.10303945988912754927e-02", | ||
"3.23714278394013899032e-02", | ||
"6.74036340750356011142e-01", | ||
"8.60542159317257970841e-01", | ||
"8.26933490794558911929e-01", | ||
"4.98793526678823928577e-01", | ||
"7.75484927475113883233e-01", | ||
"1.73766170577742240511e-01", | ||
"2.06792017792971405399e-01", | ||
"2.60017631114273228832e-01", | ||
"4.13564087123526658019e-01", | ||
"1.26147492925016369014e-01", | ||
"6.98904524885115341348e-01", | ||
"6.73539731061082447283e-01", | ||
"2.79628434956716853677e-01", | ||
"3.31844968885238955636e-01", | ||
"2.49140166071794899594e-01", | ||
"5.85038996449405157563e-02", | ||
"1.64295605653119736189e-03", | ||
"6.61688391555940835786e-01", | ||
"2.25656497910496467441e-01", | ||
"5.46632983668384309084e-01", | ||
"2.92839491432256293635e-01", | ||
"4.10792248221932831953e-01", | ||
"4.16202662888442320721e-01", | ||
"6.43227792830983524652e-01", | ||
"1.87159832050702190642e-01", | ||
"2.35471579136372843877e-01", | ||
"6.13434257495485413259e-01", | ||
"6.21319201819875210902e-01", | ||
"4.79932525302108059506e-01", | ||
"6.32427807889365922733e-01", | ||
"8.46730315308642733640e-01", | ||
"1.82994808181582424567e-01", | ||
"9.11896960112894783279e-01", | ||
"8.32949026667121561474e-01", | ||
"5.75336884747302379495e-01", | ||
"6.15001941888442482664e-01", | ||
"5.11498436403912792869e-01", | ||
"7.33132547361477815429e-01", | ||
"8.46052245800828384148e-01", | ||
"6.96024230427652934594e-01", | ||
"2.29461074712806745168e-01", | ||
"6.80039733347726604862e-01" | ||
] | ||
} | ||
} |
20
test.js
@@ -17,8 +17,16 @@ | ||
function floatview(d) { | ||
// Makes sure that the exponent has two digets like in C-printf | ||
var s = d.toExponential(20); | ||
var m = s.match(/^([0-9.]+)e(\+|-)([0-9]+)$/); | ||
var e = (m[3].length === 1) ? '0' + m[3] : m[3]; | ||
return m[1] + 'e' + m[2] + e; | ||
} | ||
test('random double', function (t) { | ||
t.test('with seed = [1, 2]', function (t) { | ||
var ref = reference['1-2']; | ||
var ref = reference.double['1-2']; | ||
var rng = xorshift.constructor([0, 1, 0, 2]); | ||
for (var i = 0; i < ref.length; i++) { | ||
t.equal(rng.random(), parseInt(ref[i], 16) / Math.pow(2, 64)); | ||
t.equal(floatview(rng.random()), ref[i]); | ||
} | ||
@@ -30,6 +38,6 @@ | ||
t.test('with seed = [3, 4]', function (t) { | ||
var ref = reference['3-4']; | ||
var ref = reference.double['3-4']; | ||
var rng = xorshift.constructor([0, 3, 0, 4]); | ||
for (var i = 0; i < ref.length; i++) { | ||
t.equal(rng.random(), parseInt(ref[i], 16) / Math.pow(2, 64)); | ||
t.equal(floatview(rng.random()), ref[i]); | ||
} | ||
@@ -45,3 +53,3 @@ | ||
t.test('with seed = [1, 2]', function (t) { | ||
var ref = reference['1-2']; | ||
var ref = reference.integer['1-2']; | ||
var rng = xorshift.constructor([0, 1, 0, 2]); | ||
@@ -56,3 +64,3 @@ for (var i = 0; i < ref.length; i++) { | ||
t.test('with seed = [3, 4]', function (t) { | ||
var ref = reference['3-4']; | ||
var ref = reference.integer['3-4']; | ||
var rng = xorshift.constructor([0, 3, 0, 4]); | ||
@@ -59,0 +67,0 @@ for (var i = 0; i < ref.length; i++) { |
@@ -95,10 +95,32 @@ | ||
*/ | ||
var CONVERTION_BUFFER = new Buffer(8); | ||
XorShift.prototype.random = function() { | ||
// :: t2 = randomint() | ||
var t2 = this.randomint(); | ||
var t2U = t2[0]; | ||
var t2L = t2[1]; | ||
// :: ret t2 / 2**64 | ||
return (t2[0] * 4294967296 + t2[1]) / 18446744073709551616; | ||
// :: e = UINT64_C(0x3FF) << 52 | ||
var eU = 0x3FF << (52 - 32); | ||
var eL = 0; | ||
// :: s = t2 >> 12 | ||
var a1 = 12; | ||
var m1 = 0xFFFFFFFF >>> (32 - a1); | ||
sU = t2U >>> a1; | ||
sL = (t2L >>> a1) | ((t2U & m1) << (32 - a1)); | ||
// :: x = e | s | ||
var xU = eU | sU; | ||
var xL = eL | sL; | ||
// :: double d = *((double *)&x) | ||
CONVERTION_BUFFER.writeUInt32BE(xU, 0, true); | ||
CONVERTION_BUFFER.writeUInt32BE(xL, 4, true); | ||
var d = CONVERTION_BUFFER.readDoubleBE(0, true); | ||
// :: d - 1 | ||
return d - 1; | ||
}; | ||
// There is nothing particularly scientific about this seed, it is just | ||
@@ -105,0 +127,0 @@ // based on the clock. |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
26454
641
0
10