MarkovM - Python library for Markov Models.
Installation
Install from Python Package Index:
pip install markovm
Install from Source Code:
pip install .
Quickstart
Create Model
You can use markovm.create_markov_model to create a Markov model. Please provide all valid states and an n-by-n matrix describing the probabilities of transitions, where n is the number of states. If two states i and j do not have a connection in between, set matrix[i][j] to 0. For example,
>>> import markovm
>>> import numpy
>>> m = markovm.create_markov_model(
... states=("A", "B", "C"),
... transitions=numpy.array([
... [0.0, 1.0, 0.0], # A must goto B
... [0.2, 0.0, 0.8], # B can goto A (20%) or C (80%)
... [0.0, 0.5, 0.5], # C can goto B or stay
... ]),
... )
Random Walk
You can use markovm.random_walk to randomly walk through a Markov model. By default, it will start with the first state. If you want it to start with another state, please provide the index of the expected starting state to index in the function call. You can also set a seed to the function call, and it uses None by default. For example,
>>> import itertools
>>> for state in itertools.islice(
... markovm.random_walk(m, seed=0), 5
... ):
... print(state)
...
A
B
C
B
A
Metadata
Release files for markovm 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| markovm-0.1.0.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| markovm-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.5 kB
Release files / markovm-0.1.0.tar.gz
| Download URL | markovm-0.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31a1190a11175943a6422454c91ed25f9e86fb470e7de04facf993d66263f4e3
|
|
BLAKE2b-256 checksum How to use checksums |
ea56b001cc15f98ce15e015cf579ff368411d4e7fe9f247639f7d151e9e328e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / markovm-0.1.0-py3-none-any.whl
| Download URL | markovm-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
38fd88e21834138ae2b4cabaa106b067d382aa5e1917e7bdc90ebc1692790e62
|
|
BLAKE2b-256 checksum How to use checksums |
567a19213b454b70b872bcaf653432a30bdb2b459a7b4751c6878bbf9207bc77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|