randc

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 7 Imported by: 0

README

随机和权重

随机

  • 分别是int、int32、int64随机
  • 查看int64 可以看到包含和不包含

权重

Documentation

Overview

Package randc 权重随机出结果 返回下标

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float32

func Float32() float32

func Float64

func Float64() float64

func GaussFloat64

func GaussFloat64(x int64, miu int64, sigma int64) float64

GaussFloat64 ... @Description: @param x @param miu @param sigma @return float64

func GaussInt64

func GaussInt64(min int64, max int64, miu int64, sigma int64) int64

GaussInt64 ... @Description: 正态(高斯)分布随机数生产器 @param min 最小值 @param max 最大值 @param miu 期望值(均值) @param sigma 方差 @return int64

func GetStringOrder

func GetStringOrder() (order string)

func RandInt

func RandInt(n int) int

RandInt [0,n)

func RandInt32

func RandInt32(n int32) int32

RandInt32 [0,n)

func RandInt64

func RandInt64(n int64) int64

RandInt64 [0,n)

func RandSection

func RandSection(min, max int64) int64

RandSection [min,max)

func RandSectionContain

func RandSectionContain(min, max int64) int64

RandSectionContain [min,max]

func RandSectionContainInt

func RandSectionContainInt(min, max int) int

RandSectionContainInt [min,max]

func RandSectionInt

func RandSectionInt(min, max int) int

RandSectionInt [min,max)

func RandomSection

func RandomSection(probability []int64) (section int)

RandomSection 总和==1000 的数组 返回概率数组下标(下标从0开始的)

func Weight

func Weight(weight []uint64) int64

Weight 随机数权重

func WeightF

func WeightF(weight []float64) int

WeightF And must be 1

func WeightedRandomIndex

func WeightedRandomIndex(weights []float32) int

Types

type IdWorker

type IdWorker struct {
	// contains filtered or unexported fields
}

func (*IdWorker) InitIdWorker

func (w *IdWorker) InitIdWorker(workerId, datacenterId int64) error

func (*IdWorker) NextId

func (w *IdWorker) NextId() (int64, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL