Documentation ¶
Overview ¶
Package mathutil provides the missing standard library math functions we need for various statistical computations.
Index ¶
- Constants
- func AbsDuration(d time.Duration) time.Duration
- func Copy(input []float64) []float64
- func CopyDurations(input []time.Duration) []time.Duration
- func CopyInts(input []int) []int
- func CopySort(input []float64) []float64
- func CopySortDurations(input []time.Duration) []time.Duration
- func CopySortInts(input []int) []int
- func DegreesAdd(baseDegrees, deltaDegrees float64) float64
- func DegreesToCompass(deg float64) float64
- func DegreesToRadians(degrees float64) float64
- func InEpsilon(a, b float64) bool
- func Max(input []float64) float64
- func MaxInts(input []int) int
- func Mean(input []float64) float64
- func MeanDurations(input []time.Duration) time.Duration
- func MeanInts(input []int) float64
- func Median(input []float64) (median float64)
- func MedianSorted(sortedInput []float64) (median float64)
- func Min(input []float64) float64
- func MinInts(input []int) int
- func MinMax(values []float64) (min, max float64)
- func MinMaxDurations(values []time.Duration) (min, max time.Duration)
- func MinMaxInts(values []int) (min, max int)
- func Mode(input []float64) []float64
- func Normalize(values ...float64) []float64
- func PercentDifference(v1, v2 float64) float64
- func PercentToRadians(pct float64) float64
- func Percentile(input []float64, percent float64) float64
- func PercentileOfDuration(input []time.Duration, percentile float64) time.Duration
- func PercentileSorted(sortedInput []float64, percent float64) float64
- func PercentileSortedDurations(sortedInput []time.Duration, percentile float64) time.Duration
- func PowInt(base int, power uint) int
- func RadianAdd(base, delta float64) float64
- func RadiansToDegrees(value float64) float64
- func RoundDown(value, roundTo float64) float64
- func RoundPlaces(input float64, places int) float64
- func RoundUp(value, roundTo float64) float64
- func StdDevP(input []float64) float64
- func StdDevS(input []float64) float64
- func Sum(input []float64) float64
- func SumDurations(values []time.Duration) time.Duration
- func SumInts(values []int) int
- func Var(input []float64, sample int) (variance float64)
- func VarP(input []float64) float64
- func VarS(input []float64) float64
- type Durations
Constants ¶
const (
// Epsilon represents the minimum amount of relevant delta we care about.
Epsilon = 0.00000001
)
Variables ¶
This section is empty.
Functions ¶
func AbsDuration ¶ added in v1.20210402.3
AbsDuration returns the absolute value of a duration.
func CopyDurations ¶
CopyDurations copies an array of time.Duration.
func CopySortDurations ¶
CopySortDurations copies and sorts an array of floats.
func CopySortInts ¶
CopySortInts copies and sorts an array of floats.
func DegreesAdd ¶
DegreesAdd adds a delta to a base in radians.
func DegreesToCompass ¶
DegreesToCompass returns the degree value in compass / clock orientation.
func DegreesToRadians ¶
DegreesToRadians returns degrees as radians.
func MeanDurations ¶
MeanDurations gets the average of a slice of numbers
func MedianSorted ¶
MedianSorted gets the median number in a sorted slice of numbers
func MinMaxDurations ¶
MinMaxDurations returns both the min and max of time.Duration in one pass.
func MinMaxInts ¶
MinMaxInts returns both the min and max of ints in one pass.
func Mode ¶
Mode gets the mode of a slice of numbers `Mode` generally is the most frequently occurring values within the input set.
func Normalize ¶
Normalize returns a set of numbers on the interval [0,1] for a given set of inputs. An example: 4,3,2,1 => 0.4, 0.3, 0.2, 0.1 Caveat; the total may be < 1.0; there are going to be issues with irrational numbers etc.
func PercentDifference ¶
PercentDifference computes the percentage difference between two values. The formula is (v2-v1)/v1.
func PercentToRadians ¶
PercentToRadians converts a normalized value (0,1) to radians.
func Percentile ¶
Percentile finds the relative standing in a slice of floats. `percent` should be given on the interval [0,100.0).
func PercentileOfDuration ¶
PercentileOfDuration finds the relative standing in a slice of durations
func PercentileSorted ¶
PercentileSorted finds the relative standing in a sorted slice of floats. `percent` should be given on the interval [0,100.0).
func PercentileSortedDurations ¶
PercentileSortedDurations finds the relative standing in a sorted slice of durations
func RadiansToDegrees ¶
RadiansToDegrees translates a radian value to a degree value.
func RoundPlaces ¶
RoundPlaces a float to a specific decimal place or precision
func SumDurations ¶
SumDurations adds all the numbers of a slice together