this is a bad commit message

This commit is contained in:
didier amyot committed 2015-10-06 23:10:21 -04:00
commit 8d7b109462
6 files changed
+188

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
package main
import (
"math"
"math/rand"
)
var normalBoxMullerAlreadyComputer bool = false
var normalBoxMullerAlreadyComputedValue float64 = 0
func NormalBoxMuller(r *rand.Rand) float64 {
if normalBoxMullerAlreadyComputer {
normalBoxMullerAlreadyComputer = false
return normalBoxMullerAlreadyComputedValue
}
radius := math.Sqrt(-2 * math.Log(r.Float64()))
theta := 2 * math.Pi * r.Float64()
normalBoxMullerAlreadyComputer = true
normalBoxMullerAlreadyComputedValue = radius * math.Cos(theta)
return radius * math.Cos(theta)
}