stat: reduce golint warnings
MODIFY
stat/distmv/studentst.go
stat/distmv/studentst.go
@@ -293,8 +293,8 @@ func (s *StudentsT) MarginalStudentsT(vars []int, src rand.Source) (dist *Studen
return NewStudentsT(newMean, &newSigma, s.nu, src)
}
-// MarginalStudentsT returns the marginal distribution of the given input variable.
-// That is, MarginalStudentsT returns
+// MarginalStudentsTSingle returns the marginal distribution of the given input variable.
+// That is, MarginalStudentsTSingle returns
// p(x_i) = \int_{x_o} p(x_i | x_o) p(x_o) dx_o
// where i is the input index, and x_o are the remaining dimensions.
// See https://en.wikipedia.org/wiki/Marginal_distribution for more information.

MODIFY
stat/distmv/uniform.go
stat/distmv/uniform.go
@@ -10,6 +10,7 @@ import (
"golang.org/x/exp/rand"
)
+// Bound represents [Min, Max] bounds.
type Bound struct {
Min float64
Max float64

MODIFY
stat/distuv/statdist.go
stat/distuv/statdist.go
@@ -65,7 +65,7 @@ func (Hellinger) DistBeta(l, r Beta) float64 {
return math.Sqrt(1 - bc)
}
-// DistHellinger computes the Hellinger distance between Normal distributions l and r.
+// DistNormal computes the Hellinger distance between Normal distributions l and r.
// See the documentation of Bhattacharyya.DistNormal for the distance formula.
func (Hellinger) DistNormal(l, r Normal) float64 {
db := Bhattacharyya{}.DistNormal(l, r)

MODIFY
stat/distuv/weibull.go
stat/distuv/weibull.go
@@ -27,9 +27,8 @@ type Weibull struct {
func (w Weibull) CDF(x float64) float64 {
if x < 0 {
return 0
- } else {
- return 1 - cmplx.Abs(cmplx.Exp(w.LogCDF(x)))
}
+ return 1 - cmplx.Abs(cmplx.Exp(w.LogCDF(x)))
}
// Entropy returns the entropy of the distribution.
@@ -51,9 +50,8 @@ func (w Weibull) gammaIPow(i, pow float64) float64 {
func (w Weibull) LogCDF(x float64) complex128 {
if x < 0 {
return 0
- } else {
- return cmplx.Log(-1) + complex(-math.Pow(x/w.Lambda, w.K), 0)
}
+ return cmplx.Log(-1) + complex(-math.Pow(x/w.Lambda, w.K), 0)
}
// LogProb computes the natural logarithm of the value of the probability
@@ -67,18 +65,16 @@ func (w Weibull) LogCDF(x float64) complex128 {
func (w Weibull) LogProb(x float64) float64 {
if x < 0 {
return 0
- } else {
- return math.Log(w.K) - math.Log(w.Lambda) + (w.K-1)*(math.Log(x)-math.Log(w.Lambda)) - math.Pow(x/w.Lambda, w.K)
}
+ return math.Log(w.K) - math.Log(w.Lambda) + (w.K-1)*(math.Log(x)-math.Log(w.Lambda)) - math.Pow(x/w.Lambda, w.K)
}
-// Survival returns the log of the survival function (complementary CDF) at x.
+// LogSurvival returns the log of the survival function (complementary CDF) at x.
func (w Weibull) LogSurvival(x float64) float64 {
if x < 0 {
return 0
- } else {
- return -math.Pow(x/w.Lambda, w.K)
}
+ return -math.Pow(x/w.Lambda, w.K)
}
// Mean returns the mean of the probability distribution.
@@ -114,9 +110,8 @@ func (Weibull) NumParameters() int {
func (w Weibull) Prob(x float64) float64 {
if x < 0 {
return 0
- } else {
- return math.Exp(w.LogProb(x))
}
+ return math.Exp(w.LogProb(x))
}
// Quantile returns the inverse of the cumulative probability distribution.

MODIFY
stat/roc.go
stat/roc.go
@@ -69,7 +69,7 @@ func ROC(n int, y []float64, classes []bool, weights []float64) (tpr, fpr []floa
}
}
- var bin int = 1 // the initial bin is known to have 0 fpr and 0 tpr
+ bin := 1 // the initial bin is known to have 0 fpr and 0 tpr
var nPos, nNeg float64
for i, u := range classes {
var posWeight, negWeight float64 = 0, 1

MODIFY
stat/samplemv/halton.go
stat/samplemv/halton.go
@@ -35,6 +35,7 @@ func (h Halton) Sample(batch *mat.Dense) {
halton(batch, h.Kind, h.Q, h.Src)
}
+// HaltonKind specifies the type of algorithm used to generate Halton samples.
type HaltonKind int
const (

MODIFY
stat/samplemv/metropolishastings.go
stat/samplemv/metropolishastings.go
@@ -30,7 +30,7 @@ type MHProposal interface {
ConditionalRand(x, y []float64) []float64
}
-// MetropolisHastings is a type for generating samples using the Metropolis Hastings
+// MetropolisHastingser is a type for generating samples using the Metropolis Hastings
// algorithm (http://en.wikipedia.org/wiki/Metropolis%E2%80%93Hastings_algorithm),
// with the given target and proposal distributions, starting at the location
// specified by Initial. If src != nil, it will be used to generate random

MODIFY
stat/sampleuv/sample.go
stat/sampleuv/sample.go
@@ -359,7 +359,7 @@ func metropolisHastings(batch []float64, initial float64, target distuv.LogProbe
}
}
-// IID generates a set of independently and identically distributed samples from
+// IIDer generates a set of independently and identically distributed samples from
// the input distribution.
type IIDer struct {
Dist distuv.Rander

MODIFY
stat/stat_test.go
stat/stat_test.go
@@ -576,7 +576,7 @@ and 0 data points above 1000. Since dividers has length 5, there will be 4 bins.
max := floats.Max(x)
// Increase the maximum divider so that the maximum value of x is contained
// within the last bucket.
- max += 1
+ max++
floats.Span(dividers, min, max)
// Span includes the min and the max. Trim the dividers to create 10 buckets
hist = Histogram(nil, dividers, x, nil)

stat: reduce golint warnings