summaryrefslogtreecommitdiff
path: root/src/pkg/rand/normal.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/rand/normal.go')
-rw-r--r--src/pkg/rand/normal.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/pkg/rand/normal.go b/src/pkg/rand/normal.go
index 25769c7bf..9ab46db9f 100644
--- a/src/pkg/rand/normal.go
+++ b/src/pkg/rand/normal.go
@@ -5,7 +5,7 @@
package rand
import (
- "math";
+ "math"
)
/*
@@ -17,14 +17,14 @@ import (
*/
const (
- rn = 3.442619855899;
+ rn = 3.442619855899
)
func absInt32(i int32) uint32 {
if i < 0 {
return uint32(-i)
}
- return uint32(i);
+ return uint32(i)
}
// NormFloat64 returns a normally distributed float64 in the range
@@ -37,9 +37,9 @@ func absInt32(i int32) uint32 {
//
func (r *Rand) NormFloat64() float64 {
for {
- j := int32(r.Uint32()); // Possibly negative
- i := j & 0x7F;
- x := float64(j) * float64(wn[i]);
+ j := int32(r.Uint32()) // Possibly negative
+ i := j & 0x7F
+ x := float64(j) * float64(wn[i])
if absInt32(j) < kn[i] {
// This case should be hit better than 99% of the time.
return x
@@ -48,8 +48,8 @@ func (r *Rand) NormFloat64() float64 {
if i == 0 {
// This extra work is only required for the base strip.
for {
- x = -math.Log(r.Float64()) * (1.0 / rn);
- y := -math.Log(r.Float64());
+ x = -math.Log(r.Float64()) * (1.0 / rn)
+ y := -math.Log(r.Float64())
if y+y >= x*x {
break
}
@@ -57,13 +57,13 @@ func (r *Rand) NormFloat64() float64 {
if j > 0 {
return rn + x
}
- return -rn - x;
+ return -rn - x
}
if fn[i]+float32(r.Float64())*(fn[i-1]-fn[i]) < float32(math.Exp(-.5*x*x)) {
return x
}
}
- panic("unreachable");
+ panic("unreachable")
}
var kn = [128]uint32{