Created
June 7, 2014 05:36
-
-
Save gmalysa/74743a96adb13be1298d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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