diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2013-04-27 18:50:38 -0700 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2013-04-27 18:50:38 -0700 |
commit | e9546a01dcb4678476157c3bcdcf8c02a0688f54 (patch) | |
tree | df3dd37025494ac479ae1deb2d5ec154ef84e720 | |
parent | d09f34cc555e60dbd57ab7c9f268daf895922225 (diff) | |
download | go-e9546a01dcb4678476157c3bcdcf8c02a0688f54.tar.gz go-e9546a01dcb4678476157c3bcdcf8c02a0688f54.zip |
math/rand: fix typo and add better crash message
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9000043
-rw-r--r-- | src/pkg/math/rand/zipf.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pkg/math/rand/zipf.go b/src/pkg/math/rand/zipf.go index 38e8ec5162..8db2c6f5bf 100644 --- a/src/pkg/math/rand/zipf.go +++ b/src/pkg/math/rand/zipf.go @@ -34,7 +34,6 @@ func (z *Zipf) hinv(x float64) float64 { // NewZipf returns a Zipf generating variates p(k) on [0, imax] // proportional to (v+k)**(-s) where s>1 and k>=0, and v>=1. -// func NewZipf(r *Rand, s float64, v float64, imax uint64) *Zipf { z := new(Zipf) if s <= 1.0 || v < 1 { @@ -52,9 +51,12 @@ func NewZipf(r *Rand, s float64, v float64, imax uint64) *Zipf { return z } -// Uint64 returns a value drawn from the Zipf distributed described +// Uint64 returns a value drawn from the Zipf distribution described // by the Zipf object. func (z *Zipf) Uint64() uint64 { + if z == nil { + panic("rand: nil Zipf") + } k := 0.0 for { |