heroku/instruments · aggregate.go
go logo
func Mean(values []int64) float64 {
	if len(values) == 0 {
		return 0.0
	}
	var sum int64
	for _, v := range values {
		sum += v
	}
	return float64(sum) / float64(len(values))
}
Similar code snippets
1.
heroku/instruments · aggregate.go
Match rating: 84.62% · See similar code snippets
go logo
func Variance(values []int64) float64 {
	if len(values) == 0 {
		return 0.0
	}
	m := Mean(values)
	var sum float64
	for _, v := range values {
		d := float64(v) - m
		sum += d * d
	}
	return float64(sum) / float64(len(values))
}
2.
ethereum/go-ethereum · sample.go
Match rating: 74.14% · See similar code snippets
go logo
func SampleVariance(values []int64) float64 {
	if 0 == len(values) {
		return 0.0
	}
	m := SampleMean(values)
	var sum float64
	for _, v := range values {
		d := float64(v) - m
		sum += d * d
	}
	return sum / float64(len(values))
}
3.
fcavani/math · stats.go
Match rating: 73.41% · See similar code snippets
go logo
func StdDevInt64(values []int64) float64 {
	// StdDevDuration: amostral
	mean := AvgInt64(values)
	var sum float64
	for _, val := range values {
		sum += (float64(val) - mean) * (float64(val) - mean)
	}
	return math.Sqrt((1.0 / float64(len(values)-1)) * sum)
}
4.
fcavani/math · stats.go
Match rating: 72.23% · See similar code snippets
go logo
func AvgInt64(values []int64) float64 {
	var sum int64
	for _, val := range values {
		sum += val
	}
	return float64(sum) / float64(len(values))
}
5.
kidoman/embd · l3gd20.go
Match rating: 72.03% · See similar code snippets
go logo
func (vs values) mean() float64 {
	sum := 0.0
	for _, v := range vs {
		sum += v
	}
	return sum / float64(len(vs))
}
6.
fcavani/math · stats.go
Match rating: 70.15% · See similar code snippets
go logo
func StdDevDuration(values []time.Duration) float64 {
	// StdDevDuration: amostral
	mean := AvgDuration(values)
	var sum float64
	for _, val := range values {
		sum += (float64(val) - mean) * (float64(val) - mean)
	}
	return math.Sqrt((1.0 / float64(len(values)-1)) * sum)
}
7.
wcharczuk/go-chart · math.go
Match rating: 69.03% · See similar code snippets
go logo
func (m mathUtil) Mean(values ...float64) float64 {
	return m.Sum(values...) / float64(len(values))
}
8.
fcavani/math · stats.go
Match rating: 65.48% · See similar code snippets
go logo
func AvgDuration(values []time.Duration) float64 {
	var sum time.Duration
	for _, val := range values {
		sum += val
	}
	return float64(sum) / float64(len(values))
}
9.
grd/stat · absdev.go
Match rating: 65.36% · See similar code snippets
go logo
func AbsdevMean(data Interface, mean float64) float64 {
	var sum float64
	Len := data.Len()

	// the sum of the absolute deviations 
	for i := 0; i < Len; i++ {
		sum += math.Abs(data.Get(i) - mean)
	}

	return sum / float64(Len)
}
10.
ethereum/go-ethereum · sample.go
Match rating: 64.88% · See similar code snippets
go logo
func SampleSum(values []int64) int64 {
	var sum int64
	for _, v := range values {
		sum += v
	}
	return sum
}