Git Product home page Git Product logo

discretemarkovchain's People

Contributors

andrewwalker avatar gvanderheide avatar ndvanforeest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

discretemarkovchain's Issues

eigenMethod does not work for a two-state Markov chain

The following does not run well:

P = np.array([[0.5,0.5],[0.6,0.4]])
mc = markovChain(P)
mc.eigenMethod()

This gives the error:
ValueError: k must be less than ndim(A)-1, k=1

As temporary fix, the powerMethod is called when the the Markov chain consists of two states.

Getting basic states from probabilities

Hi, great work here! I'm working on a simple problem and would love your feedback. Essentially, I have these States or "buttons". I have let's say initial probabilities, of a user going from one button to another. After time t1, I want to know which button he "could" be on now(or predict). After every time 't' he presses a some button button, we update the transition matrix and predict the next button. Sounds simple I'm having a hard time incorporating this with the library.. Here's a screenshot for your reference:
untitled diagram 1

memory issues for non-sparse transition matrix

I found this package super helpful for my research! There is an issue when the transition matrix is not sparse.

Issue
markovChain assumes that P is sparse. If P is not sparse (e.g. PageRank) using a sparse implementation leads to a memory explosion (and much slower code).

Solution

  • allow the use to choose if P is sparse or dense
  • write versions of the eigen-solvers that handle numpy arrays (should be mostly copy and paste)

TODO

Planned:

  • Include other methods for determining steady state distributions, such as gauss-seidel and successive-over-relaxation. It is easy to implement unvectorized versions of these algorithms, but this will be rather slow in Python.

Fixed:

  • Allow the user to specify its own sparse rate/probability matrix. This is useful and faster in case of band matrices. (Added in build 0.11)
  • Save the initial matrix so it can easily be reused. Then different methods can be compared without generating the matrix again. (Added in build 0.11)

Possibile future additions:

  • Generate the transition matrix using parellel processing. While I have some code that in principle can do this, it does not work on functions defined in a class and it can only be run after an if __name__ = "__main__" call.
  • Introduce a new class for finite Markov chains and calculate important measures such as the expected time until absorption and the probability of being absorbed in a certain state.
  • Include a class for average reward/cost Markov decision processes (a generalization of the Markov chains considered here).

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.