mathx

package
v1.2.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: MIT 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 calculates the entropy of 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 is used to test if true on given probability.

func NewProba

func NewProba() *Proba

NewProba returns a Proba.

func (*Proba) TrueOnProba

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

TrueOnProba checks if true on given probability.

type Unstable

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

A Unstable is used to generate random value around the mean value base on given deviation.

func NewUnstable

func NewUnstable(deviation float64) Unstable

NewUnstable returns a Unstable.

func (Unstable) AroundDuration

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

AroundDuration returns a random duration with given base and deviation.

func (Unstable) AroundInt

func (u Unstable) AroundInt(base int64) int64

AroundInt returns a random int64 with given base and deviation.

Jump to

Keyboard shortcuts

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