Documentation ¶
Overview ¶
The maths package provides a number of mathematical-related helpers:
distributions.go provides basic distribution-generating functions that are used primarily in testing contexts.
helpers_for_testing.go provides a testing assistents for this package and its dependents.
maths_test.go provides a test suite for all tests in the maths package hierarchy. It employs the gocheck framework for test scaffolding.
statistics.go provides basic summary statistics functions for the purpose of metrics aggregation.
statistics_test.go provides a test complement for the statistics.go module.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var IsNaN Checker = &isNaNChecker{ &CheckerInfo{Name: "IsNaN", Params: []string{"value"}}, }
This piece provides a simple tester for the gocheck testing library to ascertain if a value is not-a-number.
Functions ¶
func BinomialPDF ¶
Create calculate the value of a probability density for a given binomial statistic, where k is the target count of true cases, n is the number of subjects, and p is the probability.
func NearestRank ¶
Calculate the percentile by choosing the nearest neighboring value.
Types ¶
type ReductionMethod ¶
ReductionMethod provides a method for reducing metrics into a given scalar value.
var Average ReductionMethod = func(input []float64) float64 { count := 0.0 sum := 0.0 for _, v := range input { sum += v count++ } if count == 0 { return math.NaN() } return sum / count }
var FirstMode ReductionMethod = func(input []float64) float64 { valuesToFrequency := map[float64]int64{} var largestTally int64 = math.MinInt64 var largestTallyValue float64 = math.NaN() for _, v := range input { presentCount, _ := valuesToFrequency[v] presentCount++ valuesToFrequency[v] = presentCount if presentCount > largestTally { largestTally = presentCount largestTallyValue = v } } return largestTallyValue }
Extract the first modal value.
var Maximum ReductionMethod = func(input []float64) float64 { var maximum float64 = math.SmallestNonzeroFloat64 for _, v := range input { maximum = math.Max(maximum, v) } return maximum }
var Median ReductionMethod = NearestRankReducer(50)
var Minimum ReductionMethod = func(input []float64) float64 { var minimum float64 = math.MaxFloat64 for _, v := range input { minimum = math.Min(minimum, v) } return minimum }
func NearestRankReducer ¶
func NearestRankReducer(percentile float64) ReductionMethod
Generate a ReductionMethod based off of extracting a given percentile value.