mathutil

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNegativeCount = errors.New("negative sample count")

Error for a negative number of samples

Functions

func Linspace

func Linspace(start, stop float64, n int, endpoint bool) ([]float64, error)

n evenly spaced values from start towards stop, the last one exactly stop when endpoint is set and one step short of it otherwise

func MovingAverage

func MovingAverage(values []float64, width int) []float64

Each value replaced by the mean of the width values centred on it, the earlier side taking the extra one for an even width and positions past either end counting as zero, a NaN or infinity reaching only the means whose window holds it; as long as values, a copy for a width below two

func Percentile

func Percentile(values []float64, p float64) float64

Value p percent of the way through the sorted values, interpolated linearly between the two nearest ranks with p clamped to 0..100; NaN for no values, a NaN p or a NaN among the values

func RMS

func RMS[T sample](samples []T) float64

Root mean square of the samples, zero when there are none

func Round

func Round(x float64, digits int) float64

x rounded to digits places after the decimal point, before it when digits is negative, an exact tie in its shortest decimal form going to the even digit

Types

This section is empty.

Jump to

Keyboard shortcuts

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