Created
June 20, 2012 05:46
-
-
Save mironal/2958321 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
<script> | |
/* 乱数の発生具合を調べる */ | |
var loop = 1000000; | |
var rslt = new Array(50); /* 0 から (rslt.length - 1)までの乱数 */ | |
for(var i = 0; i < loop; i++){ | |
/* 乱数生成 */ | |
var r = Math.floor(Math.random() * rslt.length); | |
if(!rslt[r]){ | |
rslt[r] = 1; | |
}else{ | |
rslt[r]= rslt[r] + 1; | |
} | |
} | |
for(var i = 0; i < rslt.length; i++){ | |
if( Math.abs(rslt[i] - (loop / rslt.length)) > ((loop /rslt.length) / 10)){ | |
console.log("NG : rslt[" + i + "] = " + rslt[i]); | |
} | |
//console.log( i + " : " + rslt[i]); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment