Created
January 7, 2010 14:56
-
-
Save memowe/271270 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(); | |
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