maths

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrValueNotAvailable = errors.New("t-value not available for provided degrees of freedom")

	ErrUnsupportedSignifLevel = errors.New("unsupported significance level")

	ErrTooSmallDataset = errors.New("too small dataset")
)

Functions

func Max

func Max[T EssentialNumTypes](v1 ...T) T

Max finds maximum number for int, int64, float32, float64

func Min

func Min[T EssentialNumTypes](v1 ...T) T

Min finds manimum number for int, int64, float32, float64

func RoundToN

func RoundToN[T floats](value T, places int) T

func TDistribConfInterval added in v0.4.0

func TDistribConfInterval(mean, stdev float64, sampleSize int, conf SignificanceLevel) (float64, float64, error)

TDistribConfInterval calculates a confidence interval for a sample mean and standard deviation in case population std. deviation is unknown and the values are "roughly normal". Please note that the function calculates respective t-values using a simple lookup table and is reliable up to 100 degrees of freedom. Higher values will be likely approximated by 1000 df which may or may not serve well. The provided confidence level is always applied in "two tails" mode.

func TValueTwoTail added in v0.4.0

func TValueTwoTail(df int, conf SignificanceLevel) (float64, error)

TValueTwoTail gets t-value with two-tailed confidence level

func WilsonCI added in v0.4.0

func WilsonCI(succ float64, sampleSize int, signif SignificanceLevel) (float64, float64, error)

WilsonCI calculates Wilson confidence interval for a random variable with binomial distribution. The input arguments are represented as: `succ` successful trials out of `sampleSize`

Types

type EssentialNumTypes

type EssentialNumTypes interface {
	int | int64 | float32 | float64
}

type FreqInfo added in v0.5.3

type FreqInfo interface {
	Freq() int
}

type OnlineMean added in v0.3.13

type OnlineMean struct {
	// contains filtered or unexported fields
}

func (OnlineMean) Add added in v0.3.13

func (m OnlineMean) Add(incoming float64) OnlineMean

func (OnlineMean) Mean added in v0.3.13

func (m OnlineMean) Mean() float64

func (OnlineMean) Stdev added in v0.3.13

func (m OnlineMean) Stdev() float64

type Ordered added in v0.5.3

type Ordered[T any] interface {
	Get(idx int) T
	Len() int
}

type Quartiles added in v0.5.3

type Quartiles struct {
	Q1Idx int
	Q1    int
	Q2Idx int
	Q2    int
	Q3Idx int
	Q3    int
}

func GetQuartiles added in v0.5.3

func GetQuartiles[T FreqInfo](data Ordered[T]) (Quartiles, error)

GetQuartiles calculates quartiles on an ordered and (sorted) list. The function requires at least 7 items in the data. Otherwise, it returns ErrTooSmallDataset

func (Quartiles) IQR added in v0.5.3

func (q Quartiles) IQR() int

type SignificanceLevel added in v0.4.0

type SignificanceLevel string
const (
	Significance_1_00  SignificanceLevel = "1.00"
	Significance_0_50  SignificanceLevel = "0.50"
	Significance_0_40  SignificanceLevel = "0.40"
	Significance_0_30  SignificanceLevel = "0.30"
	Significance_0_20  SignificanceLevel = "0.20"
	Significance_0_10  SignificanceLevel = "0.10"
	Significance_0_05  SignificanceLevel = "0.05"
	Significance_0_02  SignificanceLevel = "0.02"
	Significance_0_01  SignificanceLevel = "0.01"
	Significance_0_002 SignificanceLevel = "0.002"
	Significance_0_001 SignificanceLevel = "0.001"
)

Jump to

Keyboard shortcuts

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