Skip to content

Instantly share code, notes, and snippets.

@gmalysa
Created June 7, 2014 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmalysa/74743a96adb13be1298d to your computer and use it in GitHub Desktop.
Save gmalysa/74743a96adb13be1298d to your computer and use it in GitHub Desktop.
WELL = require('well-rng');
_ = require('underscore');
loop_count = 1000;
burn_count = 0;
s = [];
for (i = 0; i < 32; ++i) {
s[i] = 0;
}
s[1] = 0 | (Math.random()*Math.pow(2, 32));
results = [];
rng = new WELL(s);
for (k = 0; k < burn_count; ++k) {
rng.rand();
}
for (k = 0; k < loop_count; ++k) {
results[k] = rng.rand();
}
uniques = _.uniq(results);
counts = [];
_.each(uniques, function(v, k) {
counts[k] = _.filter(results, function(v2) {
return v2 == v;
}).length;
if (counts[k] > 1)
console.log(v+' appeared '+counts[k]+' times.');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment