Skip to content

Instantly share code, notes, and snippets.

View battlecoder's full-sized avatar

Elias Zacarias battlecoder

View GitHub Profile
@battlecoder
battlecoder / rand-period-test.c
Last active December 31, 2017 20:48 — forked from unprovable/rand-period-test.c
Random Periodicity Test Code for arduino (compiled in Arduino IDE)
/*
* Test sketch based on rand-period-test.c by @unprovable
* His sketch shown an anomaly with Arduino's PRNG, in which the LCG period seems to be unreliable.
* Also the function seems to be quite slow; iterating over the stream until we get back to the beginning
* takes 199340888ms (55.3724689 hours). It takes 1.5 minutes (approx) to generate 1M numbers.
* So I decided to repeat the test with a textbook implementation of a standard LCG to see if we can get a
* reliable generator with a stable period (and hopefully faster runtime) under the same conditions.