Skip to content

Instantly share code, notes, and snippets.

@iamjono
Created November 11, 2013 15:27
Show Gist options
  • Save iamjono/7414944 to your computer and use it in GitHub Desktop.
Save iamjono/7414944 to your computer and use it in GitHub Desktop.
Box-Muller transform normal distribution method for Lasso 9
/* ============================================================
See http://rosettacode.org/wiki/Statistics/Normal_distribution#Lasso
============================================================ */
define normalDist(mean::decimal=0.5,sdev::decimal=0.2) => {
// Uses Box-Muller transform
return ((-2 * decimal_random->log)->sqrt * (2 * pi * decimal_random)->cos) * #sdev + #mean
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment