Skip to content

Instantly share code, notes, and snippets.

@jeancroy
Last active July 29, 2017 16:42
Show Gist options
  • Save jeancroy/b9e1ca362d4958166459a9ddf27d162e to your computer and use it in GitHub Desktop.
Save jeancroy/b9e1ca362d4958166459a9ddf27d162e to your computer and use it in GitHub Desktop.
// Convert uniform random [0,1] to normal random ~ N(0,1)
// norm_rnd = Probit( random() )
//
// Probit(p) ~= logit(p)*sqrt(pi/8)
// logit(p) = log( p / (1-p) )
//
Function RandomNormal(){
var c = 0.626657068657750125603941 // sqrt(pi/8)
var p = Math.random()
return c * Math.log( p/(1.0-p) )
}
@jeancroy
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment