Skip to content

breml/sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status Go Report Card
GoDoc License

Package sample

Go package sample implements sampling algorithms for 1 in n sampling for a random value (probe):

  • Modulo, using modulo-operation
  • PowerOf2, using bitwise AND-operation, only usable if the sampling rate is a power of 2
  • LowerThan, checking if the probe is lower than a pre calculated boundary (maximum value for probe divided by sampling rate)
  • Reciprocal, using a multiplication by the reciprocal value of the sampling rate (Details)
  • Decrement, implementation variant, where the random value is only calculated after a successful sampling

Install

go get github.com/breml/sample

Go generate

To generate the reciprocal_uint files use:

go generate *.go

or

go generate -tags generate .

Documentation

GoDoc

About

Go package sample implements several sampling algorithms (1 in n sampling)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published