Documentation
¶
Index ¶
- func Bool() bool
- func Bytes(n int) []byte
- func Float32() float32
- func Float64() float64
- func Int() int
- func Int16() int16
- func Int31() int32
- func Int31n(n int32) int32
- func Int32() int32
- func Int63() int64
- func Int63n(n int64) int64
- func Int64() int64
- func Intn(n int) int
- func Perm(n int) []int
- func RandomThreshold(seed *uint64, total uint64) uint64
- func Seed(seed int64)
- func Str(length int) string
- func Time() time.Time
- func Uint() uint
- func Uint16() uint16
- func Uint32() uint32
- func Uint64() uint64
- type Candidate
- type Rand
- func (r *Rand) Bool() bool
- func (r *Rand) Bytes(n int) []byte
- func (r *Rand) Float32() float32
- func (r *Rand) Float64() float64
- func (r *Rand) Int() int
- func (r *Rand) Int16() int16
- func (r *Rand) Int31() int32
- func (r *Rand) Int31n(n int32) int32
- func (r *Rand) Int32() int32
- func (r *Rand) Int63() int64
- func (r *Rand) Int63n(n int64) int64
- func (r *Rand) Int64() int64
- func (r *Rand) Intn(n int) int
- func (r *Rand) Perm(n int) []int
- func (r *Rand) Seed(seed int64)
- func (r *Rand) Str(length int) string
- func (r *Rand) Time() time.Time
- func (r *Rand) Uint() uint
- func (r *Rand) Uint16() uint16
- func (r *Rand) Uint32() uint32
- func (r *Rand) Uint64() uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandomThreshold ¶
Types ¶
type Candidate ¶
Interface for performing weighted deterministic random selection.
func RandomSamplingWithPriority ¶
func RandomSamplingWithPriority( seed uint64, candidates []Candidate, sampleSize int, totalPriority uint64) (samples []Candidate)
Select a specified number of candidates randomly from the candidate set based on each priority. This function is deterministic and will produce the same result for the same input.
Inputs: seed - 64bit integer used for random selection. candidates - A set of candidates. You get different results depending on the order. sampleSize - The number of candidates to select at random. totalPriority - The exact sum of the priorities of each candidate.
Returns: samples - A randomly selected candidate from a set of candidates. NOTE that the same candidate may have been selected in duplicate.
type Rand ¶
Rand is a prng, that is seeded with OS randomness. The OS randomness is obtained from crypto/rand, however none of the provided methods are suitable for cryptographic usage. They all utilize math/rand's prng internally.
All of the methods here are suitable for concurrent use. This is achieved by using a mutex lock on all of the provided methods.
func (*Rand) Intn ¶
Intn returns, as an int, a uniform pseudo-random number in the range [0, n). It panics if n <= 0.