Skip to main content

No project description provided

Project description

PyPI version ALNS codecov

PyKDA

pykda is a Python package for the Kemeny Decomposition Algorithm (KDA) which allows to decompose a Markov chain into clusters of states, where states within a cluster are relatively more connected to each other compared to states outside the cluster. KDA was developed in the paper from Berkhout and Heidergott (2019) and uses the Kemeny constant as a connectivity measure. The Kemeny constant is equal to the expected number of steps it takes to go from an arbitrary state to a random state drawn according to the stationary distribution of the Markov chain.

The package also contains Markov chain tooling for the calculations, for more details about these calculations and the theory, please refer to the book from Kemeny and Snell (1976).

Installation

Use the package manager pip to install PyKDA.

pip install pykda

Usage

from pykda.Markov_chain import MarkovChain
import numpy as np

P = np.array(
    [
        [0.0, 0.52493781, 0.47506219],
        [0.0, 0.66666667, 0.33333333],
        [0.06666667, 0.33333333, 0.6],
        ]
    )
MC = MarkovChain(P)

print(MC.stationary_distribution.T)
print(MC.ergodic_projector)
print(MC.mean_first_passage_matrix)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

How to cite pykda?

If you use pykda in your research, please consider citing the following paper:

Joost Berkhout, Bernd F. Heidergott (2019). Analysis of Markov influence graphs. Operations Research, 67(3):892-904. https://doi.org/10.1287/opre.2018.1813

Or, using the following BibTeX entry:

@article{Berkhout2016a,
	title = {Analysis of {Markov} influence graphs},
	volume = {67},
	number = {3},
	journal = {Operations Research},
	author = {Berkhout, J. and Heidergott, B. F.},
	year = {2019},
	pages = {892--904},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykda-0.9.1.tar.gz (65.8 kB view hashes)

Uploaded Source

Built Distribution

pykda-0.9.1-py3-none-any.whl (74.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page