sample_chain/vendor/github.com/chinuy/zipf
www-git-cn 2e1c6a2498 first commit 2024-04-18 20:31:13 +08:00
..
.gitignore first commit 2024-04-18 20:31:13 +08:00
.travis.yml first commit 2024-04-18 20:31:13 +08:00
LICENSE first commit 2024-04-18 20:31:13 +08:00
README.md first commit 2024-04-18 20:31:13 +08:00
zipf.go first commit 2024-04-18 20:31:13 +08:00

README.md

zipf Build Status

Random number generator following Zipf's law

Motivation

The built-in package implementation doesn't support alpha < 1.0.

Referring to the answer in here, here is a go version zipf generator.

The generator will randomly produce a number in the range of [0, n-1].

Usage

// import "github.com/chinuy/zipf"
r := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
z := zipf.NewZipf(r, 1.0, 10) // n = 10, alpha = 1.0
for i := 0; i < 10; i++ {
  randNumber := z.Uint64()
 // do something you want
}