function step() { var x = Math.random(); var bin = Math.floor(x * frequency.length); frequency[bin]++; sampleCount++; plotPdf(frequency, sampleCount, 1/frequency.length, "Estimated pdf of Math.random (n=" + sampleCount + ")"); } var frequency = new Array(10); var sampleCount = 0; for (var i = 0; i < frequency.length; i++) frequency[i] = 0; start("uniformCanvas", step);
Run
Stop