def least_squares(actual, axis_coords):
    a = VecOps.multiply_matrices(VecOps.transpose(axis_coords), actual)
    b = VecOps.multiply_matrices(VecOps.transpose(axis_coords), axis_coords)
    return a[0][0] / b[0][0]
def best_fit(x, terms=1, step=1):
    h = get_h(terms, len(x), step)
    a = VecOps.multiply_matrices(VecOps.transpose(h), h)
    b = VecOps.multiply_matrices(VecOps.transpose(h), x)
    c = VecOps.multiply_matrices(VecOps.get_inverse(a), b)
    return c / step
Exemplo n.º 3
0
 def test_gaussian_solve(self):
     solved = Vo.gaussian_solve(self.matrix1, self.matrix2)
     solved = Vo.multiply_matrices(self.matrix1, solved)
     for i in range(5):
         self.assertAlmostEqual(solved[i][0], self.matrix2[i][0])