Documentation ¶
Index ¶
- func Copy[T any](input []T) []T
- func CopySort[T cmp.Ordered](input []T) []T
- func Correlation[T Operatable](actual, prediction []T) float64
- func Mean[T Operatable](input []T) (mean T)
- func MeanDuration(durations []time.Duration) time.Duration
- func Median[T Operatable](values []T) T
- func MedianSorted[T Operatable](values []T) (output T)
- func MinMax[T cmp.Ordered](values []T) (min, max T)
- func Normalize[T Operatable](values []T) []float64
- func PercentChange(x1, x2 float64) float64
- func Percentile[T Operatable](input []T, percent float64) (output T)
- func PercentileSorted[T Operatable](sortedInput []T, percent float64) (percentile T)
- func RoundPlaces(input float64, places int) float64
- func Sum[T Operatable](input []T) (total T)
- func Var[T Operatable](input []T, sample int) (variance T)
- func VarP[T Operatable](input []T) T
- func VarS[T Operatable](input []T) T
- type Operatable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Correlation ¶
func Correlation[T Operatable](actual, prediction []T) float64
Correlation computes the r^2 correlation from a given set of actual values to a given set of prediction values.
An r^2 of +1.0 means perfectly correlated, and 0 means completely uncorrelated.
Because the r^2 is "squared" you will detect inverse and positive correlation with the same output value.
func MeanDuration ¶
MeanDuration returns the mean or average of a list of durations.
The underlying math is done with the `big` package so it may be slightly slower than anticipated, but this prevents overflows.
func Median ¶
func Median[T Operatable](values []T) T
Median returns the middle value from a list of _unsorted_ values.
func MedianSorted ¶
func MedianSorted[T Operatable](values []T) (output T)
MedianSorted returns the middle value from a list of _sorted_ values.
func Normalize ¶
func Normalize[T Operatable](values []T) []float64
Normalize takes a list of values and maps them onto the interval [0, 1.0].
It is important to take from the above that the output will always be on a positive interval regardless of the sign of the inputs.
func PercentChange ¶
PercentChange returns the percent change of two floats.
func Percentile ¶
func Percentile[T Operatable](input []T, percent float64) (output T)
Percentile finds the relative standing in a slice of floats. `percent` should be given on the interval [0,100.0).
func PercentileSorted ¶
func PercentileSorted[T Operatable](sortedInput []T, percent float64) (percentile T)
PercentileSorted finds the relative standing in a sorted slice of floats. `percent` should be given on the interval [0,100.0).
func RoundPlaces ¶
RoundPlaces a float to a specific decimal place or precision
func Sum ¶
func Sum[T Operatable](input []T) (total T)
Sum adds all the elements of a slice together
func Var ¶
func Var[T Operatable](input []T, sample int) (variance T)
Var finds the variance for both population and sample data
func VarP ¶
func VarP[T Operatable](input []T) T
VarP finds the amount of variance within a population
Types ¶
type Operatable ¶
Operatable are types that can be mathed.
Strictly it is the `Ordered` types less string.