mirror of
https://github.com/gonum/gonum.git
synced 2025-10-18 13:10:47 +08:00
Simplify ExKurtosis Sig
Remove mean and std from the input to ExKurtosis.
This commit is contained in:
24
stat.go
24
stat.go
@@ -265,25 +265,29 @@ func Entropy(p []float64) float64 {
|
||||
// the normal distribution is zero.
|
||||
// If weights is nil then all of the weights are 1. If weights is not nil, then
|
||||
// len(x) must equal len(weights).
|
||||
func ExKurtosis(x []float64, mean, stdev float64, weights []float64) float64 {
|
||||
func ExKurtosis(x, weights []float64) float64 {
|
||||
|
||||
// This is a three pass algorithm. There are one pass algorithms but I am
|
||||
// not aware of a two pass one, and I'm not sure about the relative stability
|
||||
// of the one pass vs three pass versions.
|
||||
|
||||
u, std := MeanStdDev(x, weights)
|
||||
if weights == nil {
|
||||
var e float64
|
||||
for _, v := range x {
|
||||
z := (v - mean) / stdev
|
||||
z := (v - u) / std
|
||||
e += z * z * z * z
|
||||
}
|
||||
mul, offset := kurtosisCorrection(float64(len(x)))
|
||||
return e*mul - offset
|
||||
}
|
||||
if len(x) != len(weights) {
|
||||
panic("stat: slice length mismatch")
|
||||
}
|
||||
|
||||
var (
|
||||
e float64
|
||||
sumWeights float64
|
||||
)
|
||||
for i, v := range x {
|
||||
z := (v - mean) / stdev
|
||||
z := (v - u) / std
|
||||
e += weights[i] * z * z * z * z
|
||||
sumWeights += weights[i]
|
||||
}
|
||||
@@ -768,12 +772,12 @@ func Quantile(p float64, c CumulantKind, x, weights []float64) float64 {
|
||||
// Skew computes the skewness of the sample data.
|
||||
// If weights is nil then all of the weights are 1. If weights is not nil, then
|
||||
// len(x) must equal len(weights).
|
||||
func Skew(x []float64, weights []float64) float64 {
|
||||
|
||||
func Skew(x, weights []float64) float64 {
|
||||
|
||||
// this is a three-pass approach. There are one pass approaches, but
|
||||
// I don't know of a two-pass one, or the numerical stability of the
|
||||
// I don't know of a two-pass one, or the numerical stability of the
|
||||
// one vs three pass version.
|
||||
|
||||
|
||||
u, std := MeanStdDev(x, weights)
|
||||
if weights == nil {
|
||||
var s float64
|
||||
|
Reference in New Issue
Block a user