-
Notifications
You must be signed in to change notification settings - Fork 134
Description
I've been occasionally hitting LinAlgError as reported in #94 or #116 and I wanted to better understand what is causing it and when does it happen. And this is one of the toy examples I came up with where I am able to reproduce it but have no idea why.
import numpy as np
arange = np.arange(0, 10).reshape(-1, 1)
coords = np.column_stack([arange, arange])
y = np.random.random(size=(10,1))
X = np.concatenate([arange, arange * 2, arange *3], axis=1)Then using this very specific bandwidth, I get the singular matrix error
mgwr.gwr.GWR(coords, y, X, bw=12.391785706039375, fixed=True).fit()But changing it even slightly to another value, larger (12.392) or smaller (12.390), makes it work again. But I am just not able to figure out where this number comes from. My first idea is that it is some specific pairwise distance but it is not.
The requirement for this to happen is collinearity within X but why does it happen for this specific bandwidth is unclear to me. Anyone has an idea?
I started digging into that to either fix it as @ljwolf suggested in #116 or to at least provide an informative error message but given I am not sure what is exactly going on I don't even know how to formulate the error.