Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 764 Bytes

README.md

File metadata and controls

22 lines (17 loc) · 764 Bytes

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
}