Documentation ¶
Overview ¶
Package utils provides some commonly used functionality.
Index ¶
- func Abs(a int) int
- func Gauss(mean, stdDev float64) float64
- func IncrementalAvrg(oldVal, newVal float64, count int) float64
- func Max(a, b int) int
- func Min(a, b int) int
- func MinMax[V Number](values []V) (min, max V)
- func WeightedAvrg(oldVal, newVal, weightFactor float64) float64
- type FloatRange
- type IntRange
- type Number
- type Rand63
- type RandFloat64
- type RandIntn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Gauss ¶
Gauss returns a normally distributed random number with the given mean and standard deviation. NOTE: mean: mu, stdDev: sigma See: https://en.wikipedia.org/wiki/Normal_distribution
func IncrementalAvrg ¶
IncrementalAvrg computes the incremental average given the old value, the new value and the previous number of samples.
func MinMax ¶
func MinMax[V Number](values []V) (min, max V)
MinMax returns the minimum and maximum value of the given slice.
func WeightedAvrg ¶
WeightedAvrg computes the weighted average given the old value, the new value and the weight factor.
Types ¶
type FloatRange ¶
type FloatRange [2]float64
FloatRange represents a minimum and maximum value.
func (FloatRange) InRange ¶
func (r FloatRange) InRange(value float64) bool
InRange returns true if the given value is within the range.
func (FloatRange) Max ¶
func (r FloatRange) Max() float64
Max FloatRange the maximum value of the range.
func (FloatRange) Min ¶
func (r FloatRange) Min() float64
Min returns the minimum value of the range.
func (FloatRange) Random ¶
func (r FloatRange) Random() float64
Random returns a random value between min and max.
type IntRange ¶
type IntRange [2]int
IntRange represents a minimum and maximum value.