mathx

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

* @Author: cnzf1 * @Date: 2022-12-13 12:02:38 * @LastEditors: cnzf1 * @LastEditTime: 2023-01-09 17:16:59 * @Description:

* @Author: cnzf1 * @Date: 2021-10-15 17:30:22 * @Last Modified by: cnzf1 * @Last Modified time: 2021-10-15 17:33:25

* @Author: cnzf1 * @Date: 2022-11-25 16:29:40 * @LastEditors: cnzf1 * @LastEditTime: 2022-11-25 16:29:51 * @Description:

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 GenerateRandomStr

func GenerateRandomStr(size int) []byte

GenerateRandomStr return a random string, size specify the string length.

func PrintFisrt0BitNum

func PrintFisrt0BitNum(s uint64) (d uint64)

从低位开始,获取s中的第一个为0的位所代表的整数 比如s=3(0011)返回4; 若s=6(0110)返回1

func PrintFisrt1BitNum

func PrintFisrt1BitNum(s uint64) (d uint64)

从低位开始,获取s中的第一个为1的位所代表的整数 比如s=3(0011)返回1; 若s=6(0110)返回2

Types

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