package main import ( "math/rand" ) // Returns a random value from a laplace // distribution with parameters u and b. func laplaceDist(u, b float64) float64 { uniform := rand.Float64() uniform -= 0.5 return u - b*sgn(uniform)*math.Log(1-2*math.Abs(uniform)) } // The signum function func sgn(x float64) flot64 { if x < 0 { return -1 } if x > 0 { return 1 } return 0 }