Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Source ¶ added in v1.10.18
type Source interface {
// Uint64 returns a random number in [0, MaxUint64] and advances the
// generator's state.
Uint64() uint64
}
type Uniform ¶
type Uniform interface {
Initialize(sampleRange uint64)
// Sample returns length numbers in the range [0,sampleRange). If there
// aren't enough numbers in the range, false is returned. If length is
// negative the implementation may panic.
Sample(length int) ([]uint64, bool)
Next() (uint64, bool)
Reset()
}
Uniform samples values without replacement in the provided range
func NewDeterministicUniform ¶ added in v1.10.18
NewDeterministicUniform returns a new sampler
type Weighted ¶
type Weighted interface {
Initialize(weights []uint64) error
Sample(sampleValue uint64) (int, bool)
}
Weighted defines how to sample a specified valued based on a provided weighted distribution
func NewWeighted ¶
func NewWeighted() Weighted
type WeightedWithoutReplacement ¶
type WeightedWithoutReplacement interface {
Initialize(weights []uint64) error
Sample(count int) ([]int, bool)
}
WeightedWithoutReplacement defines how to sample weight without replacement. Note that the behavior is to sample the weight without replacement, not the indices. So duplicate indices can be returned.
func NewDeterministicWeightedWithoutReplacement ¶ added in v1.6.0
func NewDeterministicWeightedWithoutReplacement(source Source) WeightedWithoutReplacement
NewDeterministicWeightedWithoutReplacement returns a new sampler
func NewWeightedWithoutReplacement ¶
func NewWeightedWithoutReplacement() WeightedWithoutReplacement
NewWeightedWithoutReplacement returns a new sampler
Click to show internal directories.
Click to hide internal directories.