go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/matrix/determination_coefficient_test.go (about) 1 /* 2 3 Copyright (c) 2024 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package matrix 9 10 import ( 11 "testing" 12 13 "go.charczuk.com/sdk/assert" 14 ) 15 16 func Test_DeterminationCoefficient(t *testing.T) { 17 xvalues := []float64{2, 3, 4, 6} 18 yvalues := []float64{2, 4, 6, 7} 19 coeffs := []float64{1.229, 0.143} 20 21 r2 := DeterminationCoefficient(xvalues, yvalues, coeffs) 22 assert.ItsEpsilon(t, 0.895, r2, 0.001) 23 } 24 25 func Test_computedValueFromCoeffs(t *testing.T) { 26 xvalues := []float64{2, 3, 4, 6} 27 coeffs := []float64{1.229, 0.143} 28 29 computed := computedValueFromCoeffs(xvalues[0], coeffs) 30 assert.ItsEqual(t, 2.601, computed) 31 }