Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Debugging LinAlgError - any idea what is going on? #132

@martinfleis

Description

@martinfleis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions