Skip to content

aviate-labs/rand.mo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Pseudo Random Number Generators

LFSR (linear feedback shift register)

Types of LFSR

8-bit

X^8 + X^6 + X^5 + X^4 + 1
-> 2^8 -1 = 255

16-bit

X^16 + X^14 + X^13 + X^11 + 1
-> 2^16 - 1 = 65_535

32-bit

X^32+ X^22 + X^2 + X^1 + 1
-> 2^32 - 1

Usage

let feed = LFSR.LFSR8(0);
let (v, _) = feed.next();

// Iter
let iter = LFSR.toIter(feed);

XorShift

Reference: prng.