mathx

package
v0.1.53 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0 Imports: 2 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHaversineDistance

func GetHaversineDistance(lat1, lon1, lat2, lon2 float64) float64

GetHaversineDistance finds the distance (in km) between two latitude/longitude pairs using the Haversine formula. For more details, see http://en.wikipedia.org/wiki/Haversine_formula.

func Min

func Min(a, b int) int

Min returns the minimum of two ints.

Types

type Random

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

Random is a source of random values.

func NewRandom

func NewRandom(seed int64) Random

NewRandom returns a new Random that uses the provided seed to generate random values.

func (*Random) GetExpDistributedInt

func (r *Random) GetExpDistributedInt(rate float64) int

GetExpDistributedInt returns a exponentially distributed number in the interval [0, +math.MaxFloat64), rounded to the nearest int. Callers can adjust the rate of the function through the rate parameter.

func (*Random) GetRandomInt

func (r *Random) GetRandomInt(max int) int

GetRandomInt returns a non-negative pseudo-random number in the interval [0, max). It returns 0 if max <= 0.

Jump to

Keyboard shortcuts

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