From 6ab4cd1679577a66029372f3b710e868441eb249 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:17:38 +0000 Subject: [PATCH] Bump github.com/montanaflynn/stats from 0.8.2 to 0.9.0 Bumps [github.com/montanaflynn/stats](https://github.com/montanaflynn/stats) from 0.8.2 to 0.9.0. - [Release notes](https://github.com/montanaflynn/stats/releases) - [Changelog](https://github.com/montanaflynn/stats/blob/master/CHANGELOG.md) - [Commits](https://github.com/montanaflynn/stats/compare/v0.8.2...v0.9.0) --- updated-dependencies: - dependency-name: github.com/montanaflynn/stats dependency-version: 0.9.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../montanaflynn/stats/DOCUMENTATION.md | 86 +++++++++++++++++-- .../github.com/montanaflynn/stats/README.md | 28 ++---- .../montanaflynn/stats/regression.go | 3 +- .../github.com/montanaflynn/stats/skewness.go | 62 +++++++++++++ vendor/modules.txt | 2 +- 7 files changed, 154 insertions(+), 33 deletions(-) create mode 100644 vendor/github.com/montanaflynn/stats/skewness.go diff --git a/go.mod b/go.mod index 848be78..c72feed 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/kingpin/v2 v2.4.0 github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 github.com/kubeservice-stack/common v1.9.1 - github.com/montanaflynn/stats v0.8.2 + github.com/montanaflynn/stats v0.9.0 github.com/prometheus/client_golang v1.23.2 github.com/prometheus/common v0.67.5 github.com/prometheus/exporter-toolkit v0.15.1 diff --git a/go.sum b/go.sum index ab3c9e5..8bfc5e6 100644 --- a/go.sum +++ b/go.sum @@ -45,8 +45,8 @@ github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA= github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ= github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE= -github.com/montanaflynn/stats v0.8.2 h1:52wnefTJnPI5FoHif1DQh2soKRw0yYs+4AVyvtcZCH0= -github.com/montanaflynn/stats v0.8.2/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/montanaflynn/stats v0.9.0 h1:tsBJ0RXwph9BmAuFoCmqGv6e8xa0MENQ8m0ptKq29mQ= +github.com/montanaflynn/stats v0.9.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= diff --git a/vendor/github.com/montanaflynn/stats/DOCUMENTATION.md b/vendor/github.com/montanaflynn/stats/DOCUMENTATION.md index 1ed5d3c..32ec075 100644 --- a/vendor/github.com/montanaflynn/stats/DOCUMENTATION.md +++ b/vendor/github.com/montanaflynn/stats/DOCUMENTATION.md @@ -104,6 +104,10 @@ MIT License Copyright (c) 2014-2026 Montana Flynn (Package files -[correlation.go](/src/github.com/montanaflynn/stats/correlation.go) [cumulative_sum.go](/src/github.com/montanaflynn/stats/cumulative_sum.go) [data.go](/src/github.com/montanaflynn/stats/data.go) [deviation.go](/src/github.com/montanaflynn/stats/deviation.go) [distances.go](/src/github.com/montanaflynn/stats/distances.go) [doc.go](/src/github.com/montanaflynn/stats/doc.go) [entropy.go](/src/github.com/montanaflynn/stats/entropy.go) [errors.go](/src/github.com/montanaflynn/stats/errors.go) [geometric_distribution.go](/src/github.com/montanaflynn/stats/geometric_distribution.go) [legacy.go](/src/github.com/montanaflynn/stats/legacy.go) [load.go](/src/github.com/montanaflynn/stats/load.go) [max.go](/src/github.com/montanaflynn/stats/max.go) [mean.go](/src/github.com/montanaflynn/stats/mean.go) [median.go](/src/github.com/montanaflynn/stats/median.go) [min.go](/src/github.com/montanaflynn/stats/min.go) [mode.go](/src/github.com/montanaflynn/stats/mode.go) [norm.go](/src/github.com/montanaflynn/stats/norm.go) [outlier.go](/src/github.com/montanaflynn/stats/outlier.go) [percentile.go](/src/github.com/montanaflynn/stats/percentile.go) [quartile.go](/src/github.com/montanaflynn/stats/quartile.go) [ranksum.go](/src/github.com/montanaflynn/stats/ranksum.go) [regression.go](/src/github.com/montanaflynn/stats/regression.go) [round.go](/src/github.com/montanaflynn/stats/round.go) [sample.go](/src/github.com/montanaflynn/stats/sample.go) [sigmoid.go](/src/github.com/montanaflynn/stats/sigmoid.go) [softmax.go](/src/github.com/montanaflynn/stats/softmax.go) [sum.go](/src/github.com/montanaflynn/stats/sum.go) [util.go](/src/github.com/montanaflynn/stats/util.go) [variance.go](/src/github.com/montanaflynn/stats/variance.go) +[correlation.go](/src/github.com/montanaflynn/stats/correlation.go) [cumulative_sum.go](/src/github.com/montanaflynn/stats/cumulative_sum.go) [data.go](/src/github.com/montanaflynn/stats/data.go) [describe.go](/src/github.com/montanaflynn/stats/describe.go) [deviation.go](/src/github.com/montanaflynn/stats/deviation.go) [distances.go](/src/github.com/montanaflynn/stats/distances.go) [doc.go](/src/github.com/montanaflynn/stats/doc.go) [entropy.go](/src/github.com/montanaflynn/stats/entropy.go) [errors.go](/src/github.com/montanaflynn/stats/errors.go) [geometric_distribution.go](/src/github.com/montanaflynn/stats/geometric_distribution.go) [legacy.go](/src/github.com/montanaflynn/stats/legacy.go) [load.go](/src/github.com/montanaflynn/stats/load.go) [max.go](/src/github.com/montanaflynn/stats/max.go) [mean.go](/src/github.com/montanaflynn/stats/mean.go) [median.go](/src/github.com/montanaflynn/stats/median.go) [min.go](/src/github.com/montanaflynn/stats/min.go) [mode.go](/src/github.com/montanaflynn/stats/mode.go) [norm.go](/src/github.com/montanaflynn/stats/norm.go) [outlier.go](/src/github.com/montanaflynn/stats/outlier.go) [percentile.go](/src/github.com/montanaflynn/stats/percentile.go) [quartile.go](/src/github.com/montanaflynn/stats/quartile.go) [ranksum.go](/src/github.com/montanaflynn/stats/ranksum.go) [regression.go](/src/github.com/montanaflynn/stats/regression.go) [round.go](/src/github.com/montanaflynn/stats/round.go) [sample.go](/src/github.com/montanaflynn/stats/sample.go) [sigmoid.go](/src/github.com/montanaflynn/stats/sigmoid.go) [softmax.go](/src/github.com/montanaflynn/stats/softmax.go) [sum.go](/src/github.com/montanaflynn/stats/sum.go) [util.go](/src/github.com/montanaflynn/stats/util.go) [variance.go](/src/github.com/montanaflynn/stats/variance.go) @@ -380,7 +384,7 @@ Min finds the lowest number in a set of data -## func [MinkowskiDistance](/distances.go?s=2152:2256#L75) +## func [MinkowskiDistance](/distances.go?s=2133:2237#L78) ``` go func MinkowskiDistance(dataPointX, dataPointY Float64Data, lambda float64) (distance float64, err error) ``` @@ -593,15 +597,28 @@ Pearson calculates the Pearson product-moment correlation coefficient between tw -## func [Percentile](/percentile.go?s=98:181#L8) +## func [Percentile](/percentile.go?s=598:681#L20) ``` go func Percentile(input Float64Data, percent float64) (percentile float64, err error) ``` -Percentile finds the relative standing in a slice of floats +Percentile finds the relative standing in a slice of floats. + +The function uses the Linear Interpolation Between Closest Ranks method +as recommended by NIST [1] and used by Excel (PERCENTILE), Google Sheets, +NumPy (default), and other standard tools. + +Algorithm (for percent p and sorted data of length n): + + + 1. Compute the rank: rank = (p / 100) * (n - 1) + 2. Split into integer part k and fractional part f + 3. Result = data[k] + f * (data[k+1] - data[k]) +[1] https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm -## func [PercentileNearestRank](/percentile.go?s=1079:1173#L54) + +## func [PercentileNearestRank](/percentile.go?s=1382:1476#L55) ``` go func PercentileNearestRank(input Float64Data, percent float64) (percentile float64, err error) ``` @@ -809,6 +826,65 @@ LogReg is a shortcut to LogarithmicRegression +## type [Description](/describe.go?s=89:349#L6) +``` go +type Description struct { + Count int + Mean float64 + Std float64 + Max float64 + Min float64 + DescriptionPercentiles []descriptionPercentile + AllowedNaN bool +} + +``` +Holds information about the dataset provided to Describe + + + + + + + +### func [Describe](/describe.go?s=579:672#L23) +``` go +func Describe(input Float64Data, allowNaN bool, percentiles *[]float64) (*Description, error) +``` +Describe generates descriptive statistics about a provided dataset, similar to python's pandas.describe() + + +### func [DescribePercentileFunc](/describe.go?s=917:1084#L29) +``` go +func DescribePercentileFunc(input Float64Data, allowNaN bool, percentiles *[]float64, percentileFunc func(Float64Data, float64) (float64, error)) (*Description, error) +``` +Describe generates descriptive statistics about a provided dataset, similar to python's pandas.describe() +Takes in a function to use for percentile calculation + + + + + +### func (\*Description) [String](/describe.go?s=2078:2127#L68) +``` go +func (d *Description) String(decimals int) string +``` +Represents the Description instance in a string format with specified number of decimals + + + count 3 + mean 2.00 + std 0.82 + max 3.00 + min 1.00 + 25.00% NaN + 50.00% 1.50 + 75.00% 2.50 + NaN OK true + + + + ## type [Float64Data](/data.go?s=80:106#L4) ``` go type Float64Data []float64 diff --git a/vendor/github.com/montanaflynn/stats/README.md b/vendor/github.com/montanaflynn/stats/README.md index f13ebbf..1cd4895 100644 --- a/vendor/github.com/montanaflynn/stats/README.md +++ b/vendor/github.com/montanaflynn/stats/README.md @@ -115,9 +115,12 @@ func NormVar(loc float64, scale float64) float64 {} func Pearson(data1, data2 Float64Data) (float64, error) {} func Percentile(input Float64Data, percent float64) (percentile float64, err error) {} func PercentileNearestRank(input Float64Data, percent float64) (percentile float64, err error) {} +func PopulationSkewness(input Float64Data) (float64, error) {} func PopulationVariance(input Float64Data) (pvar float64, err error) {} func Sample(input Float64Data, takenum int, replacement bool) ([]float64, error) {} +func SampleSkewness(input Float64Data) (float64, error) {} func SampleVariance(input Float64Data) (svar float64, err error) {} +func Skewness(input Float64Data) (float64, error) {} func Sigmoid(input Float64Data) ([]float64, error) {} func SoftMax(input Float64Data) ([]float64, error) {} func StableSample(input Float64Data, takenum int) ([]float64, error) {} @@ -182,32 +185,13 @@ To make things as seamless as possible please also consider the following steps: ## Releasing -This is not required by contributors and mostly here as a reminder to myself as the maintainer of this repo. To release a new version we should update the [CHANGELOG.md](/CHANGELOG.md) and [DOCUMENTATION.md](/DOCUMENTATION.md). - -First install the tools used to generate the markdown files and release: - -``` -go install github.com/davecheney/godoc2md@latest -go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest -brew tap git-chglog/git-chglog -brew install gnu-sed hub git-chglog -``` - -Then you can run these `make` directives: +Releases are automated with [GoReleaser](https://goreleaser.com/) via GitHub Actions. To create a new release, push a version tag: ``` -# Generate DOCUMENTATION.md -make docs +git tag v0.x.x +git push origin v0.x.x ``` -Then we can create a [CHANGELOG.md](/CHANGELOG.md) a new git tag and a github release: - -``` -make release TAG=v0.x.x -``` - -To authenticate `hub` for the release you will need to create a personal access token and use it as the password when it's requested. - ## MIT License Copyright (c) 2014-2026 Montana Flynn (https://montanaflynn.com) diff --git a/vendor/github.com/montanaflynn/stats/regression.go b/vendor/github.com/montanaflynn/stats/regression.go index 401d951..c883cd6 100644 --- a/vendor/github.com/montanaflynn/stats/regression.go +++ b/vendor/github.com/montanaflynn/stats/regression.go @@ -18,7 +18,7 @@ func LinearRegression(s Series) (regressions Series, err error) { } // Placeholder for the math to be done - var sum [5]float64 + var sum [4]float64 // Loop over data keeping index in place i := 0 @@ -27,7 +27,6 @@ func LinearRegression(s Series) (regressions Series, err error) { sum[1] += s[i].Y sum[2] += s[i].X * s[i].X sum[3] += s[i].X * s[i].Y - sum[4] += s[i].Y * s[i].Y } // Find gradient and intercept diff --git a/vendor/github.com/montanaflynn/stats/skewness.go b/vendor/github.com/montanaflynn/stats/skewness.go new file mode 100644 index 0000000..dcbdcea --- /dev/null +++ b/vendor/github.com/montanaflynn/stats/skewness.go @@ -0,0 +1,62 @@ +package stats + +import "math" + +// Skewness computes the population skewness of the dataset +func Skewness(input Float64Data) (float64, error) { + return PopulationSkewness(input) +} + +// PopulationSkewness computes the population skewness using the third +// central moment normalized by the cube of the standard deviation. +func PopulationSkewness(input Float64Data) (float64, error) { + if input.Len() < 2 { + return math.NaN(), ErrEmptyInput + } + + mean, _ := Mean(input) + + // Compute sum of squared and cubed differences from the mean + var sumOfSquares, sumOfCubes float64 + for _, v := range input { + d := v - mean + sumOfSquares += d * d + sumOfCubes += d * d * d + } + + if sumOfSquares == 0 { + return math.NaN(), ErrEmptyInput + } + + if sumOfCubes == 0 { + return 0.0, nil + } + + n := float64(input.Len()) + variance := sumOfSquares / n + stdDevCubed := math.Pow(variance, 3.0/2.0) + + return (sumOfCubes / n) / stdDevCubed, nil +} + +// SampleSkewness computes the adjusted Fisher-Pearson standardized moment +// coefficient, correcting for bias in small samples. +func SampleSkewness(input Float64Data) (float64, error) { + n := input.Len() + if n < 3 { + return math.NaN(), ErrEmptyInput + } + + g1, err := PopulationSkewness(input) + if err != nil { + return math.NaN(), err + } + + if g1 == 0 { + return 0.0, nil + } + + // Adjusted Fisher-Pearson: G1 = g1 * sqrt(n*(n-1)) / (n-2) + nf := float64(n) + return g1 * math.Sqrt(nf*(nf-1)) / (nf - 2), nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index e3464d8..3b3b0ea 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -55,7 +55,7 @@ github.com/mdlayher/socket # github.com/mdlayher/vsock v1.2.1 ## explicit; go 1.20 github.com/mdlayher/vsock -# github.com/montanaflynn/stats v0.8.2 +# github.com/montanaflynn/stats v0.9.0 ## explicit; go 1.13 github.com/montanaflynn/stats # github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822