From 37f15b9fa69d36be32ebe1f8de2537c9a8d38c5f Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 25 Feb 2023 13:40:16 +0100 Subject: [PATCH] fix autocorrelation: convert divisor to float64 both for Autocorrelate and AutocorrelateMP, even though for the latter the change only covers converting the divisor expression as a whole, instead of individual elements separately. --- p2/stats/stats.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/p2/stats/stats.go b/p2/stats/stats.go index 8b1cd02..184a66e 100644 --- a/p2/stats/stats.go +++ b/p2/stats/stats.go @@ -29,8 +29,7 @@ func Autocorrelate(f []float64, maxShift float64) []float64 { r += f[i] * f[i+currentShift] } - // r = r * math.Pow(float64(fLen)-float64(currentShift), -1) - r *= float64(1 / (fLen - currentShift)) + r *= 1 / float64(fLen-currentShift) v = append(v, r) @@ -53,7 +52,7 @@ func AutocorrelateMP(f []float64, maxShift float64) []float64 { r += f[i] * f[i+currentShift] } - r *= math.Pow(float64(fLen)-float64(currentShift), -1) + r *= math.Pow(float64(fLen-currentShift), -1) v = append(v, r)