this is a bad commit message
This commit is contained in:
commit
8d7b109462
6 files changed
+188
No files matched your search
@@ -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)
|
||||
}
|
||||
Reference in new issue
Block a user