Commit 6e6d9053 authored by Dr.李's avatar Dr.李

reimplementation

parent d69af2fe
......@@ -62,7 +62,7 @@ def neutralize(x: np.ndarray,
@nb.njit(nogil=True, cache=True)
def _sub_step(x, y, curr_idx, res) -> Tuple[np.ndarray, np.ndarray]:
curr_x, curr_y= x[curr_idx], y[curr_idx]
curr_x, curr_y = x[curr_idx], y[curr_idx]
b = ls_fit(curr_x, curr_y)
res[curr_idx] = ls_res(curr_x, curr_y, b)
return curr_x, b
......@@ -70,7 +70,8 @@ def _sub_step(x, y, curr_idx, res) -> Tuple[np.ndarray, np.ndarray]:
@nb.njit(nogil=True, cache=True)
def ls_fit(x: np.ndarray, y: np.ndarray) -> np.ndarray:
b = np.linalg.lstsq(x, y, rcond=-1)[0]
x_bar = x.T
b = np.linalg.pinv(x_bar @ x) @ x_bar @ y
return b
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment