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
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]