Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant calculation of Aj #10

Closed
Ziqi-Li opened this issue Apr 11, 2018 · 1 comment
Closed

Redundant calculation of Aj #10

Ziqi-Li opened this issue Apr 11, 2018 · 1 comment

Comments

@Ziqi-Li
Copy link
Member

Ziqi-Li commented Apr 11, 2018

https://github.com/pysal/gwr_private/blob/8665c8ce2459c04ba5cd9d923ac1064ba9d81729/gwr/search.py#L220

for j in range(n):
    Wj = np.diag(optim_model.W[j])
    XtW = np.dot(temp_X.T, Wj)
    XtWX_inv = np.linalg.inv(np.dot(XtW, temp_X))
    P = np.dot(XtWX_inv, XtW)
    Aj[j,:] = temp_X[j,:] * P

This loop here basically calculates hat matrix of optim_model = gwr_func(temp_y, temp_X, bw) row by row, we could just let Aj = optim_model.S to avoid the for loop and get a big speed-up.
test using GA data np.allclose(Aj, optim_model.S)yields all True.

@TaylorOshan

@TaylorOshan
Copy link
Collaborator

Aj is no longer redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants