Documentation ¶
Index ¶
- func RandChoice(array []int, n int) []int
- func RandChoiceInt32(array []int32, n int) []int32
- func RandInt(min, max int) int
- func RandInt32(min, max int32) int32
- func RandInt64(min, max int64) int64
- func RandomString(l int) string
- func Shuffle(array []int)
- func ShuffleInt32(array []int32)
- func ShuffleInt64(array []int64)
- func ShuffleUint64(array []uint64)
- func WeightedChoice(weightArray []int) int
- type AliasTable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandChoice ¶
func RandChoiceInt32 ¶
func ShuffleInt32 ¶
func ShuffleInt32(array []int32)
func ShuffleInt64 ¶
func ShuffleInt64(array []int64)
func ShuffleUint64 ¶
func ShuffleUint64(array []uint64)
Types ¶
type AliasTable ¶
type AliasTable struct {
// contains filtered or unexported fields
}
AliasTable is a discrete distribution
func NewAlias ¶
func NewAlias(weightList []int32, src rand.Source) AliasTable
新建一个抽样器,weightList是权重列表,src是随机数种子
func (*AliasTable) Next ¶
func (v *AliasTable) Next() int
Next returns the next random value from the discrete distribution
Click to show internal directories.
Click to hide internal directories.