Comments (2)
Commit 02d210a solves the issue.
Now, if the last transition matrix in the Markov chain is correctly specified (i.e. it has all the properties of a Markov matrix), function lp
automatically replaces all bad matrices with their interpolated versions.
In the case above, since matrix P[-1]
(the last one) is well-behaved, P[14]
and P[24]
are replaced by matrices interpolated from, respectively, P[13]
and P[15]
, and P[23]
and P[25]
.
from willowtree.
Update: Following commit ab317d5 the willow tree is now extremely precise. All transition matrices (including the interpolated ones) have probabilities in rows summing to 1, and the Markov chain is stationary within a very narrow tolerance level (~1e-13).
For n = 20, gamma = 0, and k = 50,
- Probabilities in rows summing to 1:
[P[i].sum(axis=1) for i in range(len(P))]
[array([ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1., 1., 1., 1., 1., 1.]),
...
array([ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1., 1., 1., 1., 1., 1.])]
- Stationary distribution:
q @ np.linalg.multi_dot([P[i] for i in range(len(P))]) - q
array([ -2.37962428e-13, -7.45986606e-13, -6.41493803e-13,
-5.86211635e-13, -5.96439564e-13, -5.60218538e-13,
-5.26273469e-13, -4.96949704e-13, -4.93674546e-13,
-4.50209314e-13, -4.37018477e-13, -4.27768931e-13,
-3.93025890e-13, -4.16118529e-13, -2.53387589e-13,
-2.46046239e-13, -1.70363723e-13, -1.71175574e-13,
5.07094366e-14, -3.53536644e-14])
Since the correctly generated transition matrices are fully well-behaved, the interpolated ones (black patches in the figure below) are as well:
from willowtree.
Related Issues (9)
- Enhancement: Scrap last matrices in the chain if bad. HOT 1
- Bug: Last replaceable matrix in the chain not replaced; vector t always shortened. HOT 3
- Bug: LP algorithm occasionally returns probabilities outside range. HOT 3
- Enhancement: Scrap first matrices in the chain if bad. HOT 1
- Enhancement: Use Python's multiprocessing to speed up the algorithm.
- Bug: Probabilities on rows of transition matrices do not sum to 1. HOT 1
- Bug: IndexError when P[0] is bad and only one matrix in the chain is well-behaved. HOT 1
- Enhancement: Plot willow tree even if no transition matrix is well-defined. Case: k > 1. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from willowtree.