r/Python • u/AutoModerator • Oct 04 '26
Showcase Showcase Thread
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
23
Upvotes
r/Python • u/AutoModerator • Oct 04 '26
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
1
u/DivinoZarathos Oct 17 '26
PyDTMC 10.0.0 — Discrete-time Markov chains and hidden Markov models in Python
I’d like to introduce PyDTMC, an open-source Python library that I’ve been developing and maintaining since 2019, focused on discrete-time Markov chains and hidden Markov models.
With the recent release of PyDTMC 10.0.0, I thought this would be a good opportunity to share the project with the Scientific Python community.
Main Capabilities
PyDTMC provides a comprehensive collection of tools for constructing, manipulating, analyzing, simulating, and visualizing finite-state Markovian stochastic processes. Its goal is to make both fundamental and more advanced Markov-chain techniques accessible through a consistent Python API.
The library covers several areas of stochastic modeling and analysis:
Markov-chain construction and manipulation: Creating chains from transition matrices or predefined models, generating random chains, and applying transformations such as censoring, lumping, and time reversal.
Structural and probabilistic analysis: Communicating classes, irreducibility, periodicity, recurrence, stationary distributions, absorption, hitting probabilities, first-passage times, and expected rewards.
Spectral and mixing analysis: Eigenvalue-based diagnostics, spectral gaps, Dobrushin and Doeblin contraction coefficients, conductance, and mixing-time measures.
Advanced Markov-chain diagnostics: Entropy production, stationary probability fluxes and currents, committor probabilities, reactive fluxes, perturbation and sensitivity analysis, and metastability-related measures.
Hidden Markov models: Construction, estimation, simulation, decoding, and prediction using transition and emission probabilities.
Visualization: Directed graphs, transition matrices, eigenvalues, state sequences, probability redistribution, and hidden-state trellises.
Example
A discrete-time Markov chain can be defined directly from its transition matrix:
The same object provides access to a wider range of structural, probabilistic, and numerical properties without requiring separate implementations of the underlying algorithms.
Installation
PyDTMC 10.0.0 requires Python 3.12 or newer and is available through PyPI:
The project is also distributed through conda-forge:
Project Links
Source Code: https://github.com/TommasoBelluzzo/PyDTMC
Documentation: https://pydtmc.readthedocs.io/
PyPI: https://pypi.org/project/PyDTMC/
Conda-forge: https://anaconda.org/conda-forge/pydtmc
Zenodo DOI: https://doi.org/10.5281/zenodo.23363778
PyDTMC is released under the MIT license. The repository includes the source code, automated tests, documentation, and examples.