Created
December 24, 2019 19:46
-
-
Save nkgokul/72577c8e0472aa8eb8b7b5722d76ed83 to your computer and use it in GitHub Desktop.
Revisions
-
nkgokul created this gist
Dec 24, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ function checkUniformDistributionOfRandom(percentateOfErrorsToLog = 10) { const percentateOfErrorsToLogFraction = percentateOfErrorsToLog/100; const threshold = 1 - percentateOfErrorsToLogFraction; const numberOfLoops = 1000; for (let i=1; i<numberOfLoops; i++){ if (Math.random() >= threshold) console.log("This should be printed " + percentateOfErrorsToLogFraction * numberOfLoops + " times"); } } [10, 20, 30, 40, 50, 60, 70, 80, 90].map(checkUniformDistributionOfRandom);