Skip to content

Instantly share code, notes, and snippets.

@intelguasoft
Created July 27, 2020 05:32
Show Gist options
  • Save intelguasoft/39c6251daf2166ff9460cf3e524974ad to your computer and use it in GitHub Desktop.
Save intelguasoft/39c6251daf2166ff9460cf3e524974ad to your computer and use it in GitHub Desktop.
Para cualquier persona curiosa, esto muestra una distribución uniforme, y los límites son inclusivos

For anyone curious, this samples a uniform distribution, and the bounds are inclusive:

Para cualquier persona curiosa, esto muestra una distribución uniforme, y los límites son inclusivos:

let counts = {};
for (let i = 0; i < 100000; i++) {
  let c = randomInt(0, 4);
  counts[c] = (counts[c] == null ? 0 : counts[c]) + 1;
}
// counts == { '0': 20035, '1': 20061, '2': 19882, '3': 20019, '4': 20003 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment