Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Created January 19, 2026 18:14
Show Gist options
  • Select an option

  • Save mattdesl/2dde1a0ffb896c63e0cce366712d4121 to your computer and use it in GitHub Desktop.

Select an option

Save mattdesl/2dde1a0ffb896c63e0cce366712d4121 to your computer and use it in GitHub Desktop.
function nextGaussianBoxMuller(mean = 0, standardDerivation = 1, rng = Math.random) {
return (
mean +
standardDerivation *
(Math.sqrt(-2.0 * Math.log(rng())) * Math.cos(TWO_PI * rng()))
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment