cdipaolo/goml · kmeans.go
go logo
func diff(u, v []float64) float64 {
	var sum float64
	for i := range u {
		sum += (u[i] - v[i]) * (u[i] - v[i])
	}

	return sum
}
Similar code snippets
1.
thoas/go-funk · typesafe.go
Match rating: 68.3% · See similar code snippets
go logo
func SumFloat64(s []float64) (sum float64) {
	for _, v := range s {
		sum += v
	}
	return
}
2.
gizak/termui · utils.go
Match rating: 67.4% · See similar code snippets
go logo
func SumFloat64Slice(data []float64) float64 {
	sum := 0.0
	for _, v := range data {
		sum += v
	}
	return sum
}
3.
GaryBoone/GoStats · stats.go
Match rating: 65.91% · See similar code snippets
go logo
func StatsSum(data []float64) (sum float64) {
	for _, v := range data {
		sum += v
	}
	return
}
4.
cdipaolo/goml · distance.go
Match rating: 61.95% · See similar code snippets
go logo
func LNorm(p int) DistanceMeasure {
	return func(u []float64, v []float64) float64 {
		var sum float64
		for i := range u {
			sum += math.Pow(u[i]-v[i], float64(p))
		}
		return math.Pow(sum, 1/float64(p))
	}
}
5.
golang/tour · channels.go
Match rating: 61.0% · See similar code snippets
go logo
func sum(s []int, c chan int) {
	sum := 0
	for _, v := range s {
		sum += v
	}
	c <- sum // send sum to c
}
6.
kidoman/embd · l3gd20.go
Match rating: 60.25% · 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))
}
7.
hprose/hprose-golang · fasthttp_hello_server.go
Match rating: 59.87% · See similar code snippets
go logo
func (Service) Sum(a ...int) int {
	sum := 0
	for _, i := range a {
		sum += i
	}
	return sum
}
8.
jdkato/prose · aptag.go
Match rating: 59.7% · See similar code snippets
go logo
func sumValues(m map[string]int) int {
	sum := 0
	for _, v := range m {
		sum += v
	}
	return sum
}
9.
lon9/mat · matrix.go
Match rating: 59.59% · See similar code snippets
go logo
func SumVec(v []float32) float32 {
	sum := float32(0.0)
	for _, e := range v {
		sum += e
	}
	return sum
}
10.
thoas/go-funk · typesafe.go
Match rating: 59.43% · See similar code snippets
go logo
func SumInt(s []int) (sum int) {
	for _, v := range s {
		sum += v
	}
	return
}