mathx

package
v0.0.0-...-115e584 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcEntropy

func CalcEntropy(m map[interface{}]int) float64

CalcEntropy 计算m的熵,熵越大就越混乱

func MaxInt

func MaxInt(a, b int) int

MaxInt returns the larger one of a and b.

func MinInt

func MinInt(a, b int) int

MinInt returns the smaller one of a and b.

Types

type Proba

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

A Proba 用来测试是否在给定的可能性以内。

func NewProba

func NewProba() *Proba

NewProba 创建一个Proba实例

func (*Proba) TrueOnProba

func (p *Proba) TrueOnProba(proba float64) (truth bool)

TrueOnProba 用来测试是否在给定的可能性以内。 proba越小,truth的可能性就越低

type Unstable

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

A Unstable 用来生成基于给定的偏差(deviation)在某个具体值(base)上下浮动的随机数。

func NewUnstable

func NewUnstable(deviation float64) Unstable

NewUnstable 返回一个Unstable对象

func (Unstable) AroundDuration

func (u Unstable) AroundDuration(base time.Duration) time.Duration

AroundDuration 基于给定的base和偏差生成一个随机时间

func (Unstable) AroundInt

func (u Unstable) AroundInt(base int64) int64

AroundInt 基于给定的base和偏差生成一个随机int64

Jump to

Keyboard shortcuts

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