Last active
July 29, 2017 16:42
-
-
Save jeancroy/b9e1ca362d4958166459a9ddf27d162e to your computer and use it in GitHub Desktop.
This file contains 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 characters
// 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) ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not very good, see
https://github.com/JuliaLang/Rmath-julia/blob/master/src/qnorm.c