8000 Preserve stationary probabilities for integer passage-time inputs by antonsoo · Pull Request #263 · pysal/giddy · GitHub
[go: up one dir, main page]

Skip to content

Preserve stationary probabilities for integer passage-time inputs - #263

Closed
antonsoo wants to merge 1 commit into
pysal:mainfrom
antonsoo:fix/integer-first-passage
Closed

antonsoo wants to merge 1 commit into
pysal:mainfrom
antonsoo:fix/integer-first-passage

Conversation

@antonsoo
Copy link
Copy Markdown

Integer transition matrices can fail in the public first-passage API:

from giddy.ergodic import mfpt

print(mfpt([[0, 1], [1, 0]]))

Before: LinAlgError: Singular matrix. After: [[2., 1.], [1., 2.]], since a step reaches the other state and two steps return to the starting state.

_mfpt_ergodic stores the fractional stationary distribution in zeros_like(P), truncating it for integer inputs. Boolean inputs also give incorrect results. Build the repeated stationary rows directly with np.tile, as var_mfpt_ergodic already does.

Add integer and boolean cycle regressions with exact passage and return times. Full tests pass on current and CI oldest dependencies. Independent graph traversal and hitting-time equations verify the correction; floating controls, including shipped income-transition analyses, remain exact. The installed wheel and composition with #262 reproduce the results.

@martinfleis
Copy link
Copy Markdown
Member

xref pysal/pointpats#216 (comment)

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

Successfully merging this pull request may close these issues.

2 participants

0