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

DigraphAbsorptionProbabilities #548

Merged
merged 3 commits into from
Apr 12, 2023

Conversation

mtorpey
Copy link
Collaborator

@mtorpey mtorpey commented Jun 12, 2022

This pull request adds the DigraphAbsorptionProbabilities attribute. Here's an explanation:

A random walk of infinite length through a digraph may pass through several different strongly connected components (SCCs). However, with probability 1 it must eventually reach an SCC which it can never leave, because the SCC has no out-edges leading to other SCCs. We may say that such an SCC has absorbed the random walk, and we can calculate the probability of each SCC absorbing a walk starting at a given vertex.

DigraphAbsorptionProbabilities returns an $m \times n$ matrix mat, where $m$ is the number of vertices in digraph and $n$ is the number of strongly connected components. Each entry mat[i][j] is a rational number representing the probability that an unbounded random walk starting at vertex i will be absorbed by strongly connected component j – that is, the probability that it will reach the component and never leave.

The algorithm is based on established theory for absorbing Markov chains. Once the strongly connected components are known, it pretty much comes down to one matrix multiplication.

This is the result of me looking into the game Soccer Dice, since I wanted to know the chance of a player scoring a goal starting from the black die. The answer is $\frac{1020}{4493}$, as shown in the test file!

@mtorpey mtorpey added enhancement A label for PRs that provide enhancements. new-feature A label for new features. and removed enhancement A label for PRs that provide enhancements. labels Jun 12, 2022
doc/attr.xml Outdated Show resolved Hide resolved
Copy link
Member

@james-d-mitchell james-d-mitchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Couple of minor comments, happy to merge after that!

@mtorpey mtorpey force-pushed the add-absorption-probs branch 2 times, most recently from d812fca to c0b594b Compare April 11, 2023 15:26
@mtorpey mtorpey force-pushed the add-absorption-probs branch from c0b594b to c87c649 Compare April 12, 2023 14:03
@mtorpey mtorpey force-pushed the add-absorption-probs branch from c87c649 to 412f1da Compare April 12, 2023 14:04
@james-d-mitchell james-d-mitchell merged commit 6e93637 into digraphs:main Apr 12, 2023
@mtorpey mtorpey deleted the add-absorption-probs branch April 12, 2023 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature A label for new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants