function step() { var x = Math.random(); var bin = Math.floor(x * frequency.length); frequency[bin]++; sampleCount++; plotCdf(frequency, sampleCount, "Estimated cdf 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