Simple CTMC solver for Python
Project description
Markon
Continous Time Markov Chain solver for Python
Markon is a small Python utility for performing analytic solution of CTMCs. Both quantitative and symbolic analysis is possible.
Example:
from markon import solve_ctmc
# Define a CTMC as a dict of state-tuples (from_state, to_state) to a transition rate
t = {('up', 'down'): 1, # Transition rate from 'up' to 'down' is 1
('down', 'up'): 5} # Transition rate from 'down' to 'up' is 5
# Obtain steady state probabilities
p = solve_ctmc(t)
print(p)
will output
{'down': 1/6, 'up': 5/6}
Individual state probabilities can be obtained, both in exact form or as a single rounded float:
print(p['up'])
print(float(p['up']))
will output
5/6
0.8333333333333334
General symbolic analysis can also be done via Sympy:
from markon import solve_ctmc
import sympy
# Define Sympy symbols
l, m = sympy.symbols('l, m')
t = {('up', 'down'): l,
('down', 'up'): m}
# Obtain steady state probabilities with defined order
p = solve_ctmc(t, ['up', 'down'])
print(p)
will output
{'up': m/(l + m), 'down': l/(l + m)}
We can then use Sympy functionality to substitute values
values = [(l, 1), (m,5)]
print(p['up'].subs(values))
will output
5/6
Refer to the Sympy documentation for more on how to enable nice formatting of expressions, output to Latex, etc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file markon-1.0.0-py3-none-any.whl.
File metadata
- Download URL: markon-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0895b96b10917f0b1a1373b5cc7ee60fd60610953540f5a23cb22d734506949
|
|
| MD5 |
2c279dbdbcdaff80f248003b8d837df8
|
|
| BLAKE2b-256 |
7bb87f564eb069a1b508ff57c3e58fe980d3f9b9d38d47e6922d6c2c001cb82c
|