Skip to content
/ zipf Public

Generate random number distributed by Zipf's law

License

Notifications You must be signed in to change notification settings

chinuy/zipf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

Generate random number distributed by Zipf's law

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages