maths

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Average

func Average[T constraints.Float](input []T) T

Average calculates the average of the elements in a slice.

This function uses rolling average calculation to sidestep issues related to overflow with large numbers in big slices.

func Ceil

func Ceil[T constraints.Float](num T, n int) T

Ceil rounds a number up to n trailing zeroes.

func CeilDecimal

func CeilDecimal[T constraints.Float](num T, n int) T

CeilDecimal rounds a number up to n decimal places.

func Collisions

func Collisions(size int, probability float64) float64

Collisions calculates the number of samples in a given set required for there to be a certain probability that there will be at least one collision. See: Birthday Problem.

func Factorial

func Factorial(n int) uint64

Factorial calculates the factorial of a given number.

func Floor

func Floor[T constraints.Float](num T, n int) T

Floor rounds a number down to n trailing zeroes.

func FloorDecimal

func FloorDecimal[T constraints.Float](num T, n int) T

FloorDecimal rounds a number down to n decimal places.

func Root

func Root(num, root float64) float64

Root calculates the nth root of a number.

func Round

func Round[T constraints.Float](num T, n int) T

Round rounds a number to the nearest n trailing zeroes.

func RoundDecimal

func RoundDecimal[T constraints.Float](num T, n int) T

RoundDecimal rounds a number to the nearest n decimal places.

func Sum

func Sum[T constraints.Integer | constraints.Float](nums []T) T

Sum calculates the sum of the elements in a slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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