-
-
Save fwg/271277 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
function drawProgress (factor) { | |
var progress = $('#progress'); | |
var bar = progress.children('#bar'); | |
var maxwidth = progress.width(); | |
factor = factor > 1 ? 1 : factor < 0 ? 0 : factor; | |
bar.width( maxwidth * factor ); | |
} | |
function calculate (params) { | |
var schwarze = new Array(); | |
var iter = 1; | |
(function f(){ | |
if (iter <= params.anzahl) { // Stichprobe | |
iter++; | |
var schw = 0; | |
for ( var i = 1; i <= params.stichprobe; i++ ) { // Ziehung | |
var zuf = 1 + Math.floor( Math.random() * params.kugeln ); | |
if ( zuf <= params.skugeln ) { | |
schw += 1; | |
} | |
} | |
schwarze.push(schw); | |
drawProgress( iter / params.anzahl ); | |
setTimeout(f,0); | |
} | |
})(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment