R=(s=~new Date,p=[],i=0,j=9)=>{
while(p.push(i)<100)--j?0:j=++i;
return _=>(s=(1+Math.sin(s))*1e5,p[100*(s-~~s)|0])
};
// test
var rnd=R()
t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0];
rgb='000,444,666,888,aaa,ddd,f0f,ff0,0ff,0ff,0f0,00f,f00,fff'.split`,`
.map(v=>(v=parseInt(v,16),[(v&15)*17,(v>>4&15)*17,(v>>8)*17]))
cnt=400*300
//for (i=0;i<cnt;i++)t[rnd()]++;
ctx = C.getContext("2d");
img=ctx.getImageData(0, 0, 400, 300)
for(p=0,y=0;y<300;y++)for(x=0;x<400;x++)
v=rnd(),t[v]++,
img.data[p++]=rgb[v][0],img.data[p++]=rgb[v][1],
img.data[p++]=rgb[v][2],img.data[p++]=255
ctx.putImageData(img, 0, 0)
o=''
for(i=0;i<14;i++)
t[i]/=cnt, o+=`<p><i>${i}</i><b style="width:${t[i]*300}%">,</b>${(t[i]*100).toFixed(2)}%</p>`;
G.innerHTML=o
#G { width: 400px; font-size: 12px; border: 1px solid #000; }
p { margin: 0}
b { display: inline-block; font-size:80%; background: #08c; margin: 2px }
i { display: inline-block; width: 20px; text-align: right; padding: 0 4px }
#C { width: 400px; height: 300px; }
<div id=G></div>
<canvas id=C></canvas>
7What about the other 9% chance? – LegionMammal978 – 2015-11-01T13:38:36.877
@LegionMammal978 I already specified. It should print 0. – ghosts_in_the_code – 2015-11-01T14:10:10.817
Yes, it's fine now. What was the problem earlier? – ghosts_in_the_code – 2015-11-01T14:12:22.863
@ghosts_in_the_code The
<
from the inequality and the>
from the quote block were forming an HTML tag. – Martin Ender – 2015-11-01T14:13:57.1332Is a resolution of seconds OK? – xnor – 2015-11-01T18:47:34.340
@xnor What does that mean? – ghosts_in_the_code – 2015-11-02T10:36:53.273
@ghosts_in_the_code That the seed only changes every second (as opposed to every millisecond, say). That is, if the random number generator is run twice within the same second, the results would be identical. – Martin Ender – 2015-11-02T15:03:03.380
@xnor Yes, it is allowed. – ghosts_in_the_code – 2015-11-02T16:28:46.110