Code Monkey home page Code Monkey logo

Comments (2)

federicomariamassari avatar federicomariamassari commented on May 24, 2024

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].

replaced

from willowtree.

federicomariamassari avatar federicomariamassari commented on May 24, 2024

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:

20-50-precise

from willowtree.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.