PyDTMC 9.0.0__tar.gz → 10.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. pydtmc-10.0.0/PKG-INFO +261 -0
  2. pydtmc-10.0.0/PyDTMC.egg-info/PKG-INFO +261 -0
  3. {pydtmc-9.0.0 → pydtmc-10.0.0}/PyDTMC.egg-info/SOURCES.txt +7 -0
  4. {pydtmc-9.0.0 → pydtmc-10.0.0}/PyDTMC.egg-info/requires.txt +3 -2
  5. pydtmc-10.0.0/README.md +192 -0
  6. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/_static/css/style.css +14 -21
  7. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/conf.py +125 -50
  8. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/hidden_markov_model_properties.rst +1 -0
  9. pydtmc-10.0.0/docs/source/index.rst +20 -0
  10. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/markov_chain_methods_instance.rst +18 -5
  11. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/markov_chain_properties.rst +13 -2
  12. pydtmc-10.0.0/docs/source/other_assessment_functions.rst +13 -0
  13. pydtmc-10.0.0/docs/source/other_comparison_functions.rst +8 -0
  14. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/other_plotting_functions.rst +2 -0
  15. pydtmc-10.0.0/pydtmc/__init__.py +74 -0
  16. pydtmc-10.0.0/pydtmc/assessments.py +798 -0
  17. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/base_classes.py +20 -2
  18. pydtmc-10.0.0/pydtmc/comparisons.py +195 -0
  19. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/computations.py +42 -120
  20. pydtmc-10.0.0/pydtmc/constants.py +25 -0
  21. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/custom_types.py +14 -14
  22. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/decorators.py +95 -7
  23. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/files_io.py +3 -3
  24. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/fitting.py +22 -35
  25. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/generators.py +328 -77
  26. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/hidden_markov_model.py +27 -12
  27. pydtmc-10.0.0/pydtmc/markov_chain.py +3980 -0
  28. pydtmc-10.0.0/pydtmc/measures.py +997 -0
  29. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/plotting.py +277 -190
  30. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/simulations.py +65 -12
  31. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/utilities.py +15 -27
  32. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/validation.py +36 -39
  33. pydtmc-10.0.0/pyproject.toml +3 -0
  34. {pydtmc-9.0.0 → pydtmc-10.0.0}/setup.cfg +21 -11
  35. {pydtmc-9.0.0 → pydtmc-10.0.0}/setup.py +2 -13
  36. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/conftest.py +57 -11
  37. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/fixtures/fixtures_aliases.json +27 -18
  38. pydtmc-10.0.0/tests/fixtures/fixtures_assessments.json +946 -0
  39. pydtmc-10.0.0/tests/fixtures/fixtures_benchmarks.json +4 -0
  40. pydtmc-10.0.0/tests/fixtures/fixtures_comparisons.json +407 -0
  41. pydtmc-10.0.0/tests/fixtures/fixtures_generators_instance.json +2157 -0
  42. pydtmc-10.0.0/tests/fixtures/fixtures_generators_static.json +1576 -0
  43. pydtmc-10.0.0/tests/fixtures/fixtures_measures.json +3599 -0
  44. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/fixtures/fixtures_plotting.json +11 -0
  45. pydtmc-10.0.0/tests/fixtures/fixtures_properties.json +2724 -0
  46. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/fixtures/fixtures_simulations.json +342 -40
  47. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/fixtures/fixtures_validation.json +1 -1
  48. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/test_aliases.py +32 -2
  49. pydtmc-10.0.0/tests/test_assessments.py +155 -0
  50. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/test_classification.py +0 -2
  51. pydtmc-10.0.0/tests/test_comparisons.py +84 -0
  52. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/test_conversions.py +1 -0
  53. pydtmc-10.0.0/tests/test_decorators.py +349 -0
  54. pydtmc-10.0.0/tests/test_generators_instance.py +276 -0
  55. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/test_generators_static.py +4 -8
  56. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/test_hmm.py +3 -3
  57. pydtmc-10.0.0/tests/test_measures.py +425 -0
  58. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/test_plotting.py +55 -0
  59. pydtmc-10.0.0/tests/test_properties.py +614 -0
  60. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/test_simulations.py +10 -0
  61. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/test_utilities.py +0 -14
  62. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/test_validation.py +6 -6
  63. pydtmc-9.0.0/PKG-INFO +0 -349
  64. pydtmc-9.0.0/PyDTMC.egg-info/PKG-INFO +0 -349
  65. pydtmc-9.0.0/README.md +0 -284
  66. pydtmc-9.0.0/docs/source/index.rst +0 -19
  67. pydtmc-9.0.0/docs/source/other_assessment_functions.rst +0 -10
  68. pydtmc-9.0.0/pydtmc/__init__.py +0 -42
  69. pydtmc-9.0.0/pydtmc/assessments.py +0 -413
  70. pydtmc-9.0.0/pydtmc/markov_chain.py +0 -2766
  71. pydtmc-9.0.0/pydtmc/measures.py +0 -685
  72. pydtmc-9.0.0/tests/fixtures/fixtures_assessments.json +0 -362
  73. pydtmc-9.0.0/tests/fixtures/fixtures_benchmarks.json +0 -6
  74. pydtmc-9.0.0/tests/fixtures/fixtures_generators_instance.json +0 -500
  75. pydtmc-9.0.0/tests/fixtures/fixtures_generators_static.json +0 -1014
  76. pydtmc-9.0.0/tests/fixtures/fixtures_measures.json +0 -1702
  77. pydtmc-9.0.0/tests/fixtures/fixtures_properties.json +0 -902
  78. pydtmc-9.0.0/tests/test_assessments.py +0 -88
  79. pydtmc-9.0.0/tests/test_generators_instance.py +0 -142
  80. pydtmc-9.0.0/tests/test_measures.py +0 -270
  81. pydtmc-9.0.0/tests/test_properties.py +0 -367
  82. {pydtmc-9.0.0 → pydtmc-10.0.0}/LICENSE.md +0 -0
  83. {pydtmc-9.0.0 → pydtmc-10.0.0}/MANIFEST.in +0 -0
  84. {pydtmc-9.0.0 → pydtmc-10.0.0}/PyDTMC.egg-info/dependency_links.txt +0 -0
  85. {pydtmc-9.0.0 → pydtmc-10.0.0}/PyDTMC.egg-info/top_level.txt +0 -0
  86. {pydtmc-9.0.0 → pydtmc-10.0.0}/data/empty +0 -0
  87. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/Makefile +0 -0
  88. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/build/empty +0 -0
  89. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/make.bat +0 -0
  90. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/_templates/empty +0 -0
  91. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/custom_exceptions.rst +0 -0
  92. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/genindex.rst +0 -0
  93. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/hidden_markov_model.rst +0 -0
  94. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/hidden_markov_model_methods_instance.rst +0 -0
  95. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/hidden_markov_model_methods_static.rst +0 -0
  96. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/markov_chain.rst +0 -0
  97. {pydtmc-9.0.0 → pydtmc-10.0.0}/docs/source/markov_chain_methods_static.rst +0 -0
  98. {pydtmc-9.0.0 → pydtmc-10.0.0}/pydtmc/exceptions.py +0 -0
  99. {pydtmc-9.0.0 → pydtmc-10.0.0}/requirements.txt +0 -0
  100. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/__init__.py +0 -0
  101. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/benchmarks.py +0 -0
  102. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/files/file_empty.txt +0 -0
  103. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/files/file_filled.txt +0 -0
  104. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/files/file_noextension +0 -0
  105. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/fixtures/fixtures_classification.json +0 -0
  106. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/fixtures/fixtures_conversions.json +0 -0
  107. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/fixtures/fixtures_fitting.json +0 -0
  108. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/fixtures/fixtures_hmm.json +0 -0
  109. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/fixtures/fixtures_utilities.json +0 -0
  110. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/test_fitting.py +0 -0
  111. {pydtmc-9.0.0 → pydtmc-10.0.0}/tests/utilities.py +0 -0
pydtmc-10.0.0/PKG-INFO ADDED
@@ -0,0 +1,261 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyDTMC
3
+ Version: 10.0.0
4
+ Summary: Python library for analyzing, simulating, and visualizing discrete-time Markov chains and hidden Markov models.
5
+ Home-page: https://github.com/TommasoBelluzzo/PyDTMC
6
+ Author: Tommaso Belluzzo
7
+ Author-email: tommaso.belluzzo@gmail.com
8
+ Maintainer: Tommaso Belluzzo
9
+ Maintainer-email: tommaso.belluzzo@gmail.com
10
+ License: MIT
11
+ Project-URL: Documentation, https://pydtmc.readthedocs.io/
12
+ Project-URL: Bug Tracker, https://github.com/TommasoBelluzzo/PyDTMC/issues
13
+ Project-URL: Donation, https://www.paypal.com/donate?hosted_button_id=D8LH6DNYN7EN8
14
+ Keywords: markov-chain,markov-chains,hidden-markov-model,hidden-markov-models,markov-model,markov-models,markov-state-model,markov-state-models,mathematics,statistics,probability,stochastic-process,stochastic-processes,scientific-computing,analysis,simulation,simulations,plot,plots,plotting
15
+ Platform: any
16
+ Classifier: Development Status :: 5 - Production/Stable
17
+ Classifier: Natural Language :: English
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Programming Language :: Python :: 3.15
25
+ Classifier: Intended Audience :: Developers
26
+ Classifier: Intended Audience :: Education
27
+ Classifier: Intended Audience :: Financial and Insurance Industry
28
+ Classifier: Intended Audience :: Science/Research
29
+ Classifier: Topic :: Education
30
+ Classifier: Topic :: Scientific/Engineering
31
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
32
+ Classifier: Topic :: Scientific/Engineering :: Visualization
33
+ Classifier: Topic :: Software Development :: Libraries
34
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
35
+ Classifier: Topic :: Other/Nonlisted Topic
36
+ Requires-Python: >=3.12
37
+ Description-Content-Type: text/markdown
38
+ License-File: LICENSE.md
39
+ Requires-Dist: matplotlib>=3.10
40
+ Requires-Dist: networkx
41
+ Requires-Dist: numpy
42
+ Requires-Dist: scipy
43
+ Provides-Extra: build
44
+ Requires-Dist: build; extra == "build"
45
+ Requires-Dist: setuptools; extra == "build"
46
+ Requires-Dist: wheel; extra == "build"
47
+ Requires-Dist: twine; extra == "build"
48
+ Provides-Extra: docs
49
+ Requires-Dist: docutils; extra == "docs"
50
+ Requires-Dist: typing-extensions; extra == "docs"
51
+ Requires-Dist: sphinx; extra == "docs"
52
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
53
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
54
+ Provides-Extra: lint
55
+ Requires-Dist: flake8; extra == "lint"
56
+ Requires-Dist: pylint; extra == "lint"
57
+ Provides-Extra: package
58
+ Requires-Dist: defusedxml; extra == "package"
59
+ Requires-Dist: numpydoc; extra == "package"
60
+ Requires-Dist: pandas; extra == "package"
61
+ Requires-Dist: pydot; extra == "package"
62
+ Provides-Extra: tests
63
+ Requires-Dist: coverage; extra == "tests"
64
+ Requires-Dist: pytest; extra == "tests"
65
+ Requires-Dist: pytest-benchmark; extra == "tests"
66
+ Requires-Dist: pytest-cov; extra == "tests"
67
+ Requires-Dist: coveralls; extra == "tests"
68
+ Dynamic: description
69
+ Dynamic: description-content-type
70
+ Dynamic: license-file
71
+
72
+ PyDTMC is a lightweight Python library focused on discrete-time Markov chains and hidden Markov models. It provides a comprehensive set of classes and functions for creating, manipulating, analyzing, simulating, and visualizing Markovian stochastic processes.
73
+
74
+ <table>
75
+ <tr>
76
+ <td align="right">Status:</td>
77
+ <td align="left">
78
+ <a href="https://github.com/TommasoBelluzzo/PyDTMC/actions/workflows/continuous_integration.yml"><img alt="Build" src="https://img.shields.io/github/actions/workflow/status/TommasoBelluzzo/PyDTMC/continuous_integration.yml?branch=master&style=flat&label=Build&color=1081C2"/></a>
79
+ <a href="https://pydtmc.readthedocs.io/"><img alt="Docs" src="https://img.shields.io/readthedocs/pydtmc?style=flat&label=Docs&color=1081C2"/></a>
80
+ <a href="https://coveralls.io/github/TommasoBelluzzo/PyDTMC?branch=master"><img alt="Coverage" src="https://img.shields.io/coveralls/github/TommasoBelluzzo/PyDTMC?style=flat&label=Coverage&color=1081C2"/></a>
81
+ </td>
82
+ </tr>
83
+ <tr>
84
+ <td align="right">Info:</td>
85
+ <td align="left">
86
+ <a href="https://github.com/TommasoBelluzzo/PyDTMC/blob/master/LICENSE.md"><img alt="License" src="https://img.shields.io/github/license/TommasoBelluzzo/PyDTMC?style=flat&label=License&color=1081C2"/></a>
87
+ <a href="https://doi.org/10.5281/zenodo.23363778"><img alt="DOI" src="https://zenodo.org/badge/DOI/10.5281/zenodo.23363778.svg"/></a>
88
+ <a href="#"><img alt="Size" src="https://img.shields.io/github/repo-size/TommasoBelluzzo/PyDTMC?style=flat&label=Size&color=1081C2"/></a>
89
+ </td>
90
+ </tr>
91
+ <tr>
92
+ <td align="right">PyPI:</td>
93
+ <td align="left">
94
+ <a href="https://pypi.org/project/PyDTMC/"><img alt="Version" src="https://img.shields.io/pypi/v/PyDTMC?style=flat&label=Version&color=1081C2"/></a>
95
+ <a href="https://pypi.org/project/PyDTMC/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/PyDTMC?style=flat&label=Python&color=1081C2"/></a>
96
+ <a href="https://pypi.org/project/PyDTMC/"><img alt="Wheel" src="https://img.shields.io/pypi/wheel/PyDTMC?style=flat&label=Wheel&color=1081C2"/></a>
97
+ <a href="https://pypi.org/project/PyDTMC/"><img alt="Downloads" src="https://img.shields.io/pypi/dm/PyDTMC?style=flat&label=Downloads&color=1081C2"/></a>
98
+ </td>
99
+ </tr>
100
+ <tr>
101
+ <td align="right">Conda:</td>
102
+ <td align="left">
103
+ <a href="https://anaconda.org/conda-forge/pydtmc/"><img alt="Version" src="https://img.shields.io/conda/vn/conda-forge/pydtmc?style=flat&label=Version"/></a>
104
+ <a href="https://anaconda.org/conda-forge/pydtmc/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/PyDTMC?style=flat&label=Python&color=1081C2"/></a>
105
+ <a href="https://anaconda.org/conda-forge/pydtmc/"><img alt="Platforms" src="https://img.shields.io/conda/pn/conda-forge/pydtmc?style=flat&label=Platforms&color=1081C2"/></a>
106
+ <a href="https://anaconda.org/conda-forge/pydtmc/"><img alt="Downloads" src="https://img.shields.io/conda/dn/conda-forge/pydtmc?style=flat&label=Downloads&color=1081C2"/></a>
107
+ </td>
108
+ </tr>
109
+ <tr>
110
+ <td align="right">Donation:</td>
111
+ <td align="left">
112
+ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D8LH6DNYN7EN8"><img alt="PayPal" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif"/></a>
113
+ </td>
114
+ </tr>
115
+ </table>
116
+
117
+ ## Installation
118
+
119
+ PyDTMC requires **Python 3.12 or greater** and depends on [NumPy](https://numpy.org/), [SciPy](https://scipy.org/), [NetworkX](https://networkx.org/), and [Matplotlib](https://matplotlib.org/).
120
+
121
+ For the [PyPI](https://pypi.org/) installation:
122
+
123
+ ```bash
124
+ pip install pydtmc
125
+ ```
126
+
127
+ For the [Conda](https://docs.conda.io/) installation:
128
+
129
+ ```bash
130
+ conda install -c conda-forge pydtmc
131
+ ```
132
+
133
+ For the latest development version:
134
+
135
+ ```bash
136
+ pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
137
+ ```
138
+
139
+ **Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
140
+
141
+ ## Quick Start
142
+
143
+ Import the classes from PyDTMC and create instances of a discrete-time Markov chain and a hidden Markov model:
144
+
145
+ ```python
146
+ from pydtmc import MarkovChain, HiddenMarkovModel
147
+
148
+ # Markov Chain
149
+
150
+ p = [
151
+ [0.2, 0.7, 0.0, 0.1],
152
+ [0.0, 0.6, 0.3, 0.1],
153
+ [0.0, 0.0, 1.0, 0.0],
154
+ [0.5, 0.0, 0.5, 0.0]
155
+ ]
156
+
157
+ mc = MarkovChain(p, ['A', 'B', 'C', 'D'])
158
+
159
+ # Hidden Markov Model
160
+
161
+ p = [
162
+ [0.4, 0.6],
163
+ [0.8, 0.2]
164
+ ]
165
+
166
+ e = [
167
+ [0.5, 0.0, 0.0, 0.5],
168
+ [0.2, 0.2, 0.2, 0.4]
169
+ ]
170
+
171
+ hmm = HiddenMarkovModel(p, e, ['A', 'B'], ['H1', 'H2', 'H3', 'H4'])
172
+ ```
173
+
174
+ ## Usage: MarkovChain Class
175
+
176
+ Using the `mc` instance created in the [Quick Start](#quick-start) section, the following examples showcase some of the class properties, methods, and visualization functions:
177
+
178
+ **Properties**
179
+
180
+ ```python
181
+ print(mc.is_absorbing)
182
+ print(mc.is_ergodic)
183
+ print(mc.is_irreducible)
184
+ print(mc.recurrent_states)
185
+ print(mc.transient_states)
186
+ print(mc.communicating_classes)
187
+ print(mc.period)
188
+ print(mc.pi)
189
+ print(mc.fundamental_matrix)
190
+ print(mc.entropy_rate)
191
+ ```
192
+
193
+ **Methods**
194
+
195
+ ```python
196
+ print(mc.absorption_probabilities())
197
+ print(mc.expected_rewards(10, [2.0, -3.0, 8.0, -7.0]))
198
+ print(mc.expected_transitions(2))
199
+ print(mc.first_passage_probabilities(5, 3))
200
+ print(mc.hitting_probabilities([0, 1]))
201
+ print(mc.mean_number_visits())
202
+ print(mc.simulate(10, seed=32))
203
+ ```
204
+
205
+ **Visualization**
206
+
207
+ ```python
208
+ from pydtmc import plot_eigenvalues, plot_graph, plot_redistributions, plot_sequence, plot_trellis
209
+
210
+ plot_eigenvalues(mc, dpi=300)
211
+ plot_graph(mc, dpi=300)
212
+ plot_sequence(mc, 10, plot_type='histogram', dpi=300)
213
+ plot_sequence(mc, 10, plot_type='heatmap', dpi=300)
214
+ plot_sequence(mc, 10, plot_type='matrix', dpi=300)
215
+ plot_redistributions(mc, 10, plot_type='heatmap', dpi=300)
216
+ plot_redistributions(mc, 10, plot_type='projection', dpi=300)
217
+ ```
218
+
219
+ ![MarkovChain Plots](https://i.imgur.com/bltMSi5.gif)
220
+
221
+ ## Usage: HiddenMarkovModel Class
222
+
223
+ Using the `hmm` instance created in the [Quick Start](#quick-start) section, the following examples showcase some of the class properties, methods, and visualization functions:
224
+
225
+ **Properties**
226
+
227
+ ```python
228
+ print(hmm.is_ergodic)
229
+ print(hmm.is_regular)
230
+ print(hmm.pi)
231
+ ```
232
+
233
+ **Methods**
234
+
235
+ ```python
236
+ print(hmm.emission_probability('H1', 'A'))
237
+ print(hmm.transition_probability('A', 'B'))
238
+ print(hmm.decode(['H1', 'H2', 'H3']))
239
+ print(hmm.predict('viterbi', ['H1', 'H2', 'H3']))
240
+ print(hmm.simulate(12, seed=1488))
241
+ ```
242
+
243
+ **Visualization**
244
+
245
+ ```python
246
+ from pydtmc import plot_graph, plot_sequence, plot_trellis
247
+
248
+ plot_graph(hmm, dpi=300)
249
+ plot_sequence(hmm, 10, plot_type='histogram', dpi=300)
250
+ plot_sequence(hmm, 10, plot_type='heatmap', dpi=300)
251
+ plot_sequence(hmm, 10, plot_type='matrix', dpi=300)
252
+ plot_trellis(hmm, 10, dpi=300)
253
+ ```
254
+
255
+ ![HiddenMarkovModel Plots](https://i.imgur.com/rSNUbdX.gif)
256
+
257
+ ## References
258
+
259
+ For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
260
+
261
+ If you use PyDTMC in your work, please cite the software using its [Zenodo DOI](https://doi.org/10.5281/zenodo.23363778).
@@ -0,0 +1,261 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyDTMC
3
+ Version: 10.0.0
4
+ Summary: Python library for analyzing, simulating, and visualizing discrete-time Markov chains and hidden Markov models.
5
+ Home-page: https://github.com/TommasoBelluzzo/PyDTMC
6
+ Author: Tommaso Belluzzo
7
+ Author-email: tommaso.belluzzo@gmail.com
8
+ Maintainer: Tommaso Belluzzo
9
+ Maintainer-email: tommaso.belluzzo@gmail.com
10
+ License: MIT
11
+ Project-URL: Documentation, https://pydtmc.readthedocs.io/
12
+ Project-URL: Bug Tracker, https://github.com/TommasoBelluzzo/PyDTMC/issues
13
+ Project-URL: Donation, https://www.paypal.com/donate?hosted_button_id=D8LH6DNYN7EN8
14
+ Keywords: markov-chain,markov-chains,hidden-markov-model,hidden-markov-models,markov-model,markov-models,markov-state-model,markov-state-models,mathematics,statistics,probability,stochastic-process,stochastic-processes,scientific-computing,analysis,simulation,simulations,plot,plots,plotting
15
+ Platform: any
16
+ Classifier: Development Status :: 5 - Production/Stable
17
+ Classifier: Natural Language :: English
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Programming Language :: Python :: 3.15
25
+ Classifier: Intended Audience :: Developers
26
+ Classifier: Intended Audience :: Education
27
+ Classifier: Intended Audience :: Financial and Insurance Industry
28
+ Classifier: Intended Audience :: Science/Research
29
+ Classifier: Topic :: Education
30
+ Classifier: Topic :: Scientific/Engineering
31
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
32
+ Classifier: Topic :: Scientific/Engineering :: Visualization
33
+ Classifier: Topic :: Software Development :: Libraries
34
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
35
+ Classifier: Topic :: Other/Nonlisted Topic
36
+ Requires-Python: >=3.12
37
+ Description-Content-Type: text/markdown
38
+ License-File: LICENSE.md
39
+ Requires-Dist: matplotlib>=3.10
40
+ Requires-Dist: networkx
41
+ Requires-Dist: numpy
42
+ Requires-Dist: scipy
43
+ Provides-Extra: build
44
+ Requires-Dist: build; extra == "build"
45
+ Requires-Dist: setuptools; extra == "build"
46
+ Requires-Dist: wheel; extra == "build"
47
+ Requires-Dist: twine; extra == "build"
48
+ Provides-Extra: docs
49
+ Requires-Dist: docutils; extra == "docs"
50
+ Requires-Dist: typing-extensions; extra == "docs"
51
+ Requires-Dist: sphinx; extra == "docs"
52
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
53
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
54
+ Provides-Extra: lint
55
+ Requires-Dist: flake8; extra == "lint"
56
+ Requires-Dist: pylint; extra == "lint"
57
+ Provides-Extra: package
58
+ Requires-Dist: defusedxml; extra == "package"
59
+ Requires-Dist: numpydoc; extra == "package"
60
+ Requires-Dist: pandas; extra == "package"
61
+ Requires-Dist: pydot; extra == "package"
62
+ Provides-Extra: tests
63
+ Requires-Dist: coverage; extra == "tests"
64
+ Requires-Dist: pytest; extra == "tests"
65
+ Requires-Dist: pytest-benchmark; extra == "tests"
66
+ Requires-Dist: pytest-cov; extra == "tests"
67
+ Requires-Dist: coveralls; extra == "tests"
68
+ Dynamic: description
69
+ Dynamic: description-content-type
70
+ Dynamic: license-file
71
+
72
+ PyDTMC is a lightweight Python library focused on discrete-time Markov chains and hidden Markov models. It provides a comprehensive set of classes and functions for creating, manipulating, analyzing, simulating, and visualizing Markovian stochastic processes.
73
+
74
+ <table>
75
+ <tr>
76
+ <td align="right">Status:</td>
77
+ <td align="left">
78
+ <a href="https://github.com/TommasoBelluzzo/PyDTMC/actions/workflows/continuous_integration.yml"><img alt="Build" src="https://img.shields.io/github/actions/workflow/status/TommasoBelluzzo/PyDTMC/continuous_integration.yml?branch=master&style=flat&label=Build&color=1081C2"/></a>
79
+ <a href="https://pydtmc.readthedocs.io/"><img alt="Docs" src="https://img.shields.io/readthedocs/pydtmc?style=flat&label=Docs&color=1081C2"/></a>
80
+ <a href="https://coveralls.io/github/TommasoBelluzzo/PyDTMC?branch=master"><img alt="Coverage" src="https://img.shields.io/coveralls/github/TommasoBelluzzo/PyDTMC?style=flat&label=Coverage&color=1081C2"/></a>
81
+ </td>
82
+ </tr>
83
+ <tr>
84
+ <td align="right">Info:</td>
85
+ <td align="left">
86
+ <a href="https://github.com/TommasoBelluzzo/PyDTMC/blob/master/LICENSE.md"><img alt="License" src="https://img.shields.io/github/license/TommasoBelluzzo/PyDTMC?style=flat&label=License&color=1081C2"/></a>
87
+ <a href="https://doi.org/10.5281/zenodo.23363778"><img alt="DOI" src="https://zenodo.org/badge/DOI/10.5281/zenodo.23363778.svg"/></a>
88
+ <a href="#"><img alt="Size" src="https://img.shields.io/github/repo-size/TommasoBelluzzo/PyDTMC?style=flat&label=Size&color=1081C2"/></a>
89
+ </td>
90
+ </tr>
91
+ <tr>
92
+ <td align="right">PyPI:</td>
93
+ <td align="left">
94
+ <a href="https://pypi.org/project/PyDTMC/"><img alt="Version" src="https://img.shields.io/pypi/v/PyDTMC?style=flat&label=Version&color=1081C2"/></a>
95
+ <a href="https://pypi.org/project/PyDTMC/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/PyDTMC?style=flat&label=Python&color=1081C2"/></a>
96
+ <a href="https://pypi.org/project/PyDTMC/"><img alt="Wheel" src="https://img.shields.io/pypi/wheel/PyDTMC?style=flat&label=Wheel&color=1081C2"/></a>
97
+ <a href="https://pypi.org/project/PyDTMC/"><img alt="Downloads" src="https://img.shields.io/pypi/dm/PyDTMC?style=flat&label=Downloads&color=1081C2"/></a>
98
+ </td>
99
+ </tr>
100
+ <tr>
101
+ <td align="right">Conda:</td>
102
+ <td align="left">
103
+ <a href="https://anaconda.org/conda-forge/pydtmc/"><img alt="Version" src="https://img.shields.io/conda/vn/conda-forge/pydtmc?style=flat&label=Version"/></a>
104
+ <a href="https://anaconda.org/conda-forge/pydtmc/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/PyDTMC?style=flat&label=Python&color=1081C2"/></a>
105
+ <a href="https://anaconda.org/conda-forge/pydtmc/"><img alt="Platforms" src="https://img.shields.io/conda/pn/conda-forge/pydtmc?style=flat&label=Platforms&color=1081C2"/></a>
106
+ <a href="https://anaconda.org/conda-forge/pydtmc/"><img alt="Downloads" src="https://img.shields.io/conda/dn/conda-forge/pydtmc?style=flat&label=Downloads&color=1081C2"/></a>
107
+ </td>
108
+ </tr>
109
+ <tr>
110
+ <td align="right">Donation:</td>
111
+ <td align="left">
112
+ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D8LH6DNYN7EN8"><img alt="PayPal" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif"/></a>
113
+ </td>
114
+ </tr>
115
+ </table>
116
+
117
+ ## Installation
118
+
119
+ PyDTMC requires **Python 3.12 or greater** and depends on [NumPy](https://numpy.org/), [SciPy](https://scipy.org/), [NetworkX](https://networkx.org/), and [Matplotlib](https://matplotlib.org/).
120
+
121
+ For the [PyPI](https://pypi.org/) installation:
122
+
123
+ ```bash
124
+ pip install pydtmc
125
+ ```
126
+
127
+ For the [Conda](https://docs.conda.io/) installation:
128
+
129
+ ```bash
130
+ conda install -c conda-forge pydtmc
131
+ ```
132
+
133
+ For the latest development version:
134
+
135
+ ```bash
136
+ pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
137
+ ```
138
+
139
+ **Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
140
+
141
+ ## Quick Start
142
+
143
+ Import the classes from PyDTMC and create instances of a discrete-time Markov chain and a hidden Markov model:
144
+
145
+ ```python
146
+ from pydtmc import MarkovChain, HiddenMarkovModel
147
+
148
+ # Markov Chain
149
+
150
+ p = [
151
+ [0.2, 0.7, 0.0, 0.1],
152
+ [0.0, 0.6, 0.3, 0.1],
153
+ [0.0, 0.0, 1.0, 0.0],
154
+ [0.5, 0.0, 0.5, 0.0]
155
+ ]
156
+
157
+ mc = MarkovChain(p, ['A', 'B', 'C', 'D'])
158
+
159
+ # Hidden Markov Model
160
+
161
+ p = [
162
+ [0.4, 0.6],
163
+ [0.8, 0.2]
164
+ ]
165
+
166
+ e = [
167
+ [0.5, 0.0, 0.0, 0.5],
168
+ [0.2, 0.2, 0.2, 0.4]
169
+ ]
170
+
171
+ hmm = HiddenMarkovModel(p, e, ['A', 'B'], ['H1', 'H2', 'H3', 'H4'])
172
+ ```
173
+
174
+ ## Usage: MarkovChain Class
175
+
176
+ Using the `mc` instance created in the [Quick Start](#quick-start) section, the following examples showcase some of the class properties, methods, and visualization functions:
177
+
178
+ **Properties**
179
+
180
+ ```python
181
+ print(mc.is_absorbing)
182
+ print(mc.is_ergodic)
183
+ print(mc.is_irreducible)
184
+ print(mc.recurrent_states)
185
+ print(mc.transient_states)
186
+ print(mc.communicating_classes)
187
+ print(mc.period)
188
+ print(mc.pi)
189
+ print(mc.fundamental_matrix)
190
+ print(mc.entropy_rate)
191
+ ```
192
+
193
+ **Methods**
194
+
195
+ ```python
196
+ print(mc.absorption_probabilities())
197
+ print(mc.expected_rewards(10, [2.0, -3.0, 8.0, -7.0]))
198
+ print(mc.expected_transitions(2))
199
+ print(mc.first_passage_probabilities(5, 3))
200
+ print(mc.hitting_probabilities([0, 1]))
201
+ print(mc.mean_number_visits())
202
+ print(mc.simulate(10, seed=32))
203
+ ```
204
+
205
+ **Visualization**
206
+
207
+ ```python
208
+ from pydtmc import plot_eigenvalues, plot_graph, plot_redistributions, plot_sequence, plot_trellis
209
+
210
+ plot_eigenvalues(mc, dpi=300)
211
+ plot_graph(mc, dpi=300)
212
+ plot_sequence(mc, 10, plot_type='histogram', dpi=300)
213
+ plot_sequence(mc, 10, plot_type='heatmap', dpi=300)
214
+ plot_sequence(mc, 10, plot_type='matrix', dpi=300)
215
+ plot_redistributions(mc, 10, plot_type='heatmap', dpi=300)
216
+ plot_redistributions(mc, 10, plot_type='projection', dpi=300)
217
+ ```
218
+
219
+ ![MarkovChain Plots](https://i.imgur.com/bltMSi5.gif)
220
+
221
+ ## Usage: HiddenMarkovModel Class
222
+
223
+ Using the `hmm` instance created in the [Quick Start](#quick-start) section, the following examples showcase some of the class properties, methods, and visualization functions:
224
+
225
+ **Properties**
226
+
227
+ ```python
228
+ print(hmm.is_ergodic)
229
+ print(hmm.is_regular)
230
+ print(hmm.pi)
231
+ ```
232
+
233
+ **Methods**
234
+
235
+ ```python
236
+ print(hmm.emission_probability('H1', 'A'))
237
+ print(hmm.transition_probability('A', 'B'))
238
+ print(hmm.decode(['H1', 'H2', 'H3']))
239
+ print(hmm.predict('viterbi', ['H1', 'H2', 'H3']))
240
+ print(hmm.simulate(12, seed=1488))
241
+ ```
242
+
243
+ **Visualization**
244
+
245
+ ```python
246
+ from pydtmc import plot_graph, plot_sequence, plot_trellis
247
+
248
+ plot_graph(hmm, dpi=300)
249
+ plot_sequence(hmm, 10, plot_type='histogram', dpi=300)
250
+ plot_sequence(hmm, 10, plot_type='heatmap', dpi=300)
251
+ plot_sequence(hmm, 10, plot_type='matrix', dpi=300)
252
+ plot_trellis(hmm, 10, dpi=300)
253
+ ```
254
+
255
+ ![HiddenMarkovModel Plots](https://i.imgur.com/rSNUbdX.gif)
256
+
257
+ ## References
258
+
259
+ For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
260
+
261
+ If you use PyDTMC in your work, please cite the software using its [Zenodo DOI](https://doi.org/10.5281/zenodo.23363778).
@@ -1,6 +1,7 @@
1
1
  LICENSE.md
2
2
  MANIFEST.in
3
3
  README.md
4
+ pyproject.toml
4
5
  requirements.txt
5
6
  setup.cfg
6
7
  setup.py
@@ -26,13 +27,16 @@ docs/source/markov_chain_methods_instance.rst
26
27
  docs/source/markov_chain_methods_static.rst
27
28
  docs/source/markov_chain_properties.rst
28
29
  docs/source/other_assessment_functions.rst
30
+ docs/source/other_comparison_functions.rst
29
31
  docs/source/other_plotting_functions.rst
30
32
  docs/source/_static/css/style.css
31
33
  docs/source/_templates/empty
32
34
  pydtmc/__init__.py
33
35
  pydtmc/assessments.py
34
36
  pydtmc/base_classes.py
37
+ pydtmc/comparisons.py
35
38
  pydtmc/computations.py
39
+ pydtmc/constants.py
36
40
  pydtmc/custom_types.py
37
41
  pydtmc/decorators.py
38
42
  pydtmc/exceptions.py
@@ -52,7 +56,9 @@ tests/conftest.py
52
56
  tests/test_aliases.py
53
57
  tests/test_assessments.py
54
58
  tests/test_classification.py
59
+ tests/test_comparisons.py
55
60
  tests/test_conversions.py
61
+ tests/test_decorators.py
56
62
  tests/test_fitting.py
57
63
  tests/test_generators_instance.py
58
64
  tests/test_generators_static.py
@@ -71,6 +77,7 @@ tests/fixtures/fixtures_aliases.json
71
77
  tests/fixtures/fixtures_assessments.json
72
78
  tests/fixtures/fixtures_benchmarks.json
73
79
  tests/fixtures/fixtures_classification.json
80
+ tests/fixtures/fixtures_comparisons.json
74
81
  tests/fixtures/fixtures_conversions.json
75
82
  tests/fixtures/fixtures_fitting.json
76
83
  tests/fixtures/fixtures_generators_instance.json
@@ -4,14 +4,15 @@ numpy
4
4
  scipy
5
5
 
6
6
  [build]
7
+ build
7
8
  setuptools
8
9
  wheel
9
10
  twine
10
11
 
11
12
  [docs]
12
- docutils<0.21,>=0.18.1
13
+ docutils
13
14
  typing-extensions
14
- sphinx<=7.1.2
15
+ sphinx
15
16
  sphinx-autodoc-typehints
16
17
  sphinx-rtd-theme
17
18