source: node_modules/d3-random/src/lcg.js@ e4c61dd

Last change on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 360 bytes
Line 
1// https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use
2const mul = 0x19660D;
3const inc = 0x3C6EF35F;
4const eps = 1 / 0x100000000;
5
6export default function lcg(seed = Math.random()) {
7 let state = (0 <= seed && seed < 1 ? seed / eps : Math.abs(seed)) | 0;
8 return () => (state = mul * state + inc | 0, eps * (state >>> 0));
9}
Note: See TracBrowser for help on using the repository browser.