# Edit in JSFiddle

// CHANGE THE INITIAL SEED HERE
Math.seed = 6;

/**
* Math.seededRandom()
*
*/
Math.seededRandom = function(max, min) {
max = max || 1;
min = min || 0;

Math.seed = (Math.seed * 9301 + 49297) % 233280;
var rnd = Math.seed / 233280.0;

return min + rnd * (max - min);
}

var c, r = 0,
l = 100000,
t,
random = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
seededRandom = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

// do some loops withouth benchmarking
// to have a "fair" comparison
for (c = 0; c < l; ++c) {
r = 5+5;
}

// benchmark Math.random()
t = new Date().getTime();
for (c = 0; c < l; ++c) {
r = Math.random();
random[(r * 10) | 0] += 1;
}
s = '';
s += ('<p>Time for generating ' + l + ' random numbers: <br/>');
s += ('Math.random(): <b>' + (new Date().getTime()-t) + 'ms</b>' );
s += ('<br />Random distribution '+random.join(', ')+' <hr /> ');

// benchmark Math.seededRandom()
t = new Date().getTime();
for ( c = 0; c < l; ++c ) {
r = Math.seededRandom();
seededRandom[(r*10)|0] += 1;
}
s += ('Math.seededRandom(): <b>' + (new Date().getTime()-t) + 'ms</b>' );
s += ('<br />Random distribution '+seededRandom.join(', ') + '</p>');
\$('body').html(s);

body {
font-family: "Segoe UI", sans-serif;
font-size: 14px;
line-height: 24px;