Skip to content

Instantly share code, notes, and snippets.

@memowe
Created January 7, 2010 14:56
Show Gist options
  • Save memowe/271270 to your computer and use it in GitHub Desktop.
Save memowe/271270 to your computer and use it in GitHub Desktop.
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();
for ( var iter = 1; iter <= params.anzahl; iter++ ) { // Stichprobe
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 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment