diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2015-07-03 11:11:42 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2015-07-03 21:39:04 +0000 |
commit | 71832ff489fdca6f41fe5f5bc8ca56976c7fc5aa (patch) | |
tree | cf35ada2765264deb688ef8365aa73647bec253f | |
parent | 40a1516a098b9843e2d3e5ee2b9471a57d6f2470 (diff) | |
download | go-71832ff489fdca6f41fe5f5bc8ca56976c7fc5aa.tar.gz go-71832ff489fdca6f41fe5f5bc8ca56976c7fc5aa.zip |
math/rand: improve NewZipf documentation
Change-Id: I78f0f9ac33db153c4a0d7f9866da20ebcd3d3639
Reviewed-on: https://go-review.googlesource.com/11872
Reviewed-by: Rob Pike <r@golang.org>
-rw-r--r-- | src/math/rand/zipf.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/math/rand/zipf.go b/src/math/rand/zipf.go index 8db2c6f5bf..f04c814eb7 100644 --- a/src/math/rand/zipf.go +++ b/src/math/rand/zipf.go @@ -32,8 +32,10 @@ func (z *Zipf) hinv(x float64) float64 { return math.Exp(z.oneminusQinv*math.Log(z.oneminusQ*x)) - z.v } -// 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. +// NewZipf returns a Zipf variate generator. +// The generator generates values k ∈ [0, imax] +// such that P(k) is proportional to (v + k) ** (-s). +// Requirements: s > 1 and v >= 1. func NewZipf(r *Rand, s float64, v float64, imax uint64) *Zipf { z := new(Zipf) if s <= 1.0 || v < 1 { |