PyDTMC 10.0.0__tar.gz → 11.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 (157) hide show
  1. {pydtmc-10.0.0 → pydtmc-11.0.0}/MANIFEST.in +1 -0
  2. {pydtmc-10.0.0 → pydtmc-11.0.0}/PKG-INFO +13 -19
  3. {pydtmc-10.0.0 → pydtmc-11.0.0}/PyDTMC.egg-info/PKG-INFO +13 -19
  4. pydtmc-11.0.0/PyDTMC.egg-info/SOURCES.txt +123 -0
  5. {pydtmc-10.0.0 → pydtmc-11.0.0}/PyDTMC.egg-info/requires.txt +0 -1
  6. {pydtmc-10.0.0 → pydtmc-11.0.0}/README.md +12 -17
  7. {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/source/_static/css/style.css +4 -0
  8. pydtmc-11.0.0/docs/source/advanced_topics/absorbing_markov_chains.rst +146 -0
  9. pydtmc-11.0.0/docs/source/advanced_topics/assessments.rst +214 -0
  10. pydtmc-11.0.0/docs/source/advanced_topics/chain_comparison.rst +155 -0
  11. pydtmc-11.0.0/docs/source/advanced_topics/hidden_markov_models.rst +159 -0
  12. pydtmc-11.0.0/docs/source/advanced_topics/hitting_passage.rst +145 -0
  13. pydtmc-11.0.0/docs/source/advanced_topics/index.rst +21 -0
  14. pydtmc-11.0.0/docs/source/advanced_topics/long_term_behavior.rst +138 -0
  15. pydtmc-11.0.0/docs/source/advanced_topics/markov_chain_analysis.rst +146 -0
  16. pydtmc-11.0.0/docs/source/advanced_topics/mixing_convergence.rst +203 -0
  17. pydtmc-11.0.0/docs/source/advanced_topics/reduction_aggregation.rst +139 -0
  18. pydtmc-11.0.0/docs/source/advanced_topics/simulation_empirical_analysis.rst +132 -0
  19. pydtmc-11.0.0/docs/source/advanced_topics/transition_paths_analysis.rst +131 -0
  20. pydtmc-11.0.0/docs/source/advanced_topics/visualization.rst +152 -0
  21. {pydtmc-10.0.0/docs/source → pydtmc-11.0.0/docs/source/api_reference}/custom_exceptions.rst +5 -5
  22. pydtmc-11.0.0/docs/source/api_reference/hidden_markov_model.rst +15 -0
  23. pydtmc-11.0.0/docs/source/api_reference/hidden_markov_model_methods_instance.rst +36 -0
  24. pydtmc-11.0.0/docs/source/api_reference/hidden_markov_model_methods_static.rst +18 -0
  25. pydtmc-11.0.0/docs/source/api_reference/hidden_markov_model_properties.rst +23 -0
  26. pydtmc-11.0.0/docs/source/api_reference/index.rst +19 -0
  27. pydtmc-11.0.0/docs/source/api_reference/markov_chain.rst +14 -0
  28. pydtmc-11.0.0/docs/source/api_reference/markov_chain_methods_instance.rst +76 -0
  29. pydtmc-11.0.0/docs/source/api_reference/markov_chain_methods_static.rst +34 -0
  30. pydtmc-11.0.0/docs/source/api_reference/markov_chain_properties.rst +65 -0
  31. {pydtmc-10.0.0/docs/source → pydtmc-11.0.0/docs/source/api_reference}/other_assessment_functions.rst +3 -1
  32. {pydtmc-10.0.0/docs/source → pydtmc-11.0.0/docs/source/api_reference}/other_comparison_functions.rst +2 -0
  33. {pydtmc-10.0.0/docs/source → pydtmc-11.0.0/docs/source/api_reference}/other_plotting_functions.rst +7 -2
  34. {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/source/conf.py +76 -4
  35. {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/source/genindex.rst +1 -1
  36. pydtmc-11.0.0/docs/source/getting_started/first_hidden_markov_model.rst +52 -0
  37. pydtmc-11.0.0/docs/source/getting_started/first_markov_chain.rst +57 -0
  38. pydtmc-11.0.0/docs/source/getting_started/index.rst +11 -0
  39. pydtmc-11.0.0/docs/source/getting_started/installation.rst +27 -0
  40. pydtmc-11.0.0/docs/source/index.rst +17 -0
  41. {pydtmc-10.0.0 → pydtmc-11.0.0}/pydtmc/__init__.py +20 -4
  42. pydtmc-11.0.0/pydtmc/_analysis.py +2572 -0
  43. pydtmc-10.0.0/pydtmc/base_classes.py → pydtmc-11.0.0/pydtmc/_base_classes.py +4 -8
  44. pydtmc-11.0.0/pydtmc/_custom_types.py +466 -0
  45. pydtmc-10.0.0/pydtmc/decorators.py → pydtmc-11.0.0/pydtmc/_decorators.py +7 -7
  46. pydtmc-11.0.0/pydtmc/_dynamics.py +388 -0
  47. pydtmc-10.0.0/pydtmc/files_io.py → pydtmc-11.0.0/pydtmc/_files_io.py +17 -19
  48. pydtmc-11.0.0/pydtmc/_fitting.py +462 -0
  49. pydtmc-11.0.0/pydtmc/_generators.py +2135 -0
  50. pydtmc-11.0.0/pydtmc/_numerical.py +599 -0
  51. pydtmc-11.0.0/pydtmc/_rendering.py +2152 -0
  52. pydtmc-10.0.0/pydtmc/utilities.py → pydtmc-11.0.0/pydtmc/_utilities.py +70 -85
  53. pydtmc-10.0.0/pydtmc/validation.py → pydtmc-11.0.0/pydtmc/_validation.py +529 -371
  54. {pydtmc-10.0.0 → pydtmc-11.0.0}/pydtmc/assessments.py +286 -126
  55. pydtmc-11.0.0/pydtmc/comparisons.py +332 -0
  56. pydtmc-11.0.0/pydtmc/hidden_markov_model.py +1706 -0
  57. pydtmc-11.0.0/pydtmc/markov_chain.py +4480 -0
  58. pydtmc-11.0.0/pydtmc/plotting.py +535 -0
  59. {pydtmc-10.0.0 → pydtmc-11.0.0}/setup.cfg +6 -8
  60. {pydtmc-10.0.0 → pydtmc-11.0.0}/setup.py +2 -2
  61. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/benchmarks.py +3 -3
  62. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/conftest.py +28 -20
  63. pydtmc-11.0.0/tests/files/file_filled.txt +1 -0
  64. pydtmc-11.0.0/tests/fixtures/fixtures_aliases.json +279 -0
  65. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_assessments.json +327 -127
  66. pydtmc-11.0.0/tests/fixtures/fixtures_comparisons.json +802 -0
  67. pydtmc-11.0.0/tests/fixtures/fixtures_hmm.json +5548 -0
  68. pydtmc-11.0.0/tests/fixtures/fixtures_hmm_classification.json +150 -0
  69. pydtmc-11.0.0/tests/fixtures/fixtures_hmm_dynamics.json +2537 -0
  70. pydtmc-11.0.0/tests/fixtures/fixtures_hmm_fitting.json +617 -0
  71. pydtmc-11.0.0/tests/fixtures/fixtures_hmm_generators_instance.json +329 -0
  72. pydtmc-11.0.0/tests/fixtures/fixtures_hmm_generators_static.json +795 -0
  73. pydtmc-11.0.0/tests/fixtures/fixtures_hmm_measures.json +1810 -0
  74. pydtmc-11.0.0/tests/fixtures/fixtures_hmm_properties.json +444 -0
  75. pydtmc-11.0.0/tests/fixtures/fixtures_mc_classification.json +208 -0
  76. pydtmc-10.0.0/tests/fixtures/fixtures_simulations.json → pydtmc-11.0.0/tests/fixtures/fixtures_mc_dynamics.json +671 -167
  77. pydtmc-11.0.0/tests/fixtures/fixtures_mc_fitting.json +420 -0
  78. pydtmc-10.0.0/tests/fixtures/fixtures_generators_instance.json → pydtmc-11.0.0/tests/fixtures/fixtures_mc_generators_instance.json +866 -0
  79. pydtmc-10.0.0/tests/fixtures/fixtures_generators_static.json → pydtmc-11.0.0/tests/fixtures/fixtures_mc_generators_static.json +1193 -135
  80. pydtmc-11.0.0/tests/fixtures/fixtures_mc_measures.json +8114 -0
  81. pydtmc-10.0.0/tests/fixtures/fixtures_properties.json → pydtmc-11.0.0/tests/fixtures/fixtures_mc_properties.json +506 -1
  82. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_plotting.json +29 -4
  83. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_utilities.json +107 -0
  84. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_validation.json +3575 -1430
  85. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/test_aliases.py +97 -6
  86. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/test_assessments.py +44 -24
  87. pydtmc-11.0.0/tests/test_comparisons.py +142 -0
  88. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/test_conversions.py +7 -0
  89. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/test_decorators.py +27 -2
  90. pydtmc-11.0.0/tests/test_hmm_classification.py +26 -0
  91. pydtmc-11.0.0/tests/test_hmm_dynamics.py +257 -0
  92. pydtmc-11.0.0/tests/test_hmm_fitting.py +228 -0
  93. pydtmc-11.0.0/tests/test_hmm_generators_instance.py +57 -0
  94. pydtmc-11.0.0/tests/test_hmm_generators_static.py +141 -0
  95. pydtmc-11.0.0/tests/test_hmm_measures.py +174 -0
  96. pydtmc-11.0.0/tests/test_hmm_properties.py +145 -0
  97. pydtmc-10.0.0/tests/test_classification.py → pydtmc-11.0.0/tests/test_mc_classification.py +24 -0
  98. pydtmc-10.0.0/tests/test_simulations.py → pydtmc-11.0.0/tests/test_mc_dynamics.py +26 -8
  99. pydtmc-10.0.0/tests/test_fitting.py → pydtmc-11.0.0/tests/test_mc_fitting.py +8 -2
  100. pydtmc-11.0.0/tests/test_mc_generators_instance.py +482 -0
  101. pydtmc-11.0.0/tests/test_mc_generators_static.py +338 -0
  102. pydtmc-10.0.0/tests/test_measures.py → pydtmc-11.0.0/tests/test_mc_measures.py +176 -31
  103. pydtmc-10.0.0/tests/test_properties.py → pydtmc-11.0.0/tests/test_mc_properties.py +112 -23
  104. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/test_plotting.py +118 -110
  105. pydtmc-11.0.0/tests/test_utilities.py +206 -0
  106. pydtmc-11.0.0/tests/test_validation.py +690 -0
  107. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/utilities.py +20 -2
  108. pydtmc-10.0.0/PyDTMC.egg-info/SOURCES.txt +0 -91
  109. pydtmc-10.0.0/docs/source/hidden_markov_model.rst +0 -15
  110. pydtmc-10.0.0/docs/source/hidden_markov_model_methods_instance.rst +0 -19
  111. pydtmc-10.0.0/docs/source/hidden_markov_model_methods_static.rst +0 -15
  112. pydtmc-10.0.0/docs/source/hidden_markov_model_properties.rst +0 -18
  113. pydtmc-10.0.0/docs/source/index.rst +0 -20
  114. pydtmc-10.0.0/docs/source/markov_chain.rst +0 -15
  115. pydtmc-10.0.0/docs/source/markov_chain_methods_instance.rst +0 -63
  116. pydtmc-10.0.0/docs/source/markov_chain_methods_static.rst +0 -23
  117. pydtmc-10.0.0/docs/source/markov_chain_properties.rst +0 -61
  118. pydtmc-10.0.0/pydtmc/comparisons.py +0 -195
  119. pydtmc-10.0.0/pydtmc/computations.py +0 -270
  120. pydtmc-10.0.0/pydtmc/custom_types.py +0 -366
  121. pydtmc-10.0.0/pydtmc/fitting.py +0 -317
  122. pydtmc-10.0.0/pydtmc/generators.py +0 -1312
  123. pydtmc-10.0.0/pydtmc/hidden_markov_model.py +0 -988
  124. pydtmc-10.0.0/pydtmc/markov_chain.py +0 -3980
  125. pydtmc-10.0.0/pydtmc/measures.py +0 -997
  126. pydtmc-10.0.0/pydtmc/plotting.py +0 -1633
  127. pydtmc-10.0.0/pydtmc/simulations.py +0 -284
  128. pydtmc-10.0.0/tests/files/file_noextension +0 -0
  129. pydtmc-10.0.0/tests/fixtures/fixtures_aliases.json +0 -105
  130. pydtmc-10.0.0/tests/fixtures/fixtures_classification.json +0 -92
  131. pydtmc-10.0.0/tests/fixtures/fixtures_comparisons.json +0 -407
  132. pydtmc-10.0.0/tests/fixtures/fixtures_fitting.json +0 -160
  133. pydtmc-10.0.0/tests/fixtures/fixtures_hmm.json +0 -1765
  134. pydtmc-10.0.0/tests/fixtures/fixtures_measures.json +0 -3599
  135. pydtmc-10.0.0/tests/test_comparisons.py +0 -84
  136. pydtmc-10.0.0/tests/test_generators_instance.py +0 -276
  137. pydtmc-10.0.0/tests/test_generators_static.py +0 -138
  138. pydtmc-10.0.0/tests/test_hmm.py +0 -285
  139. pydtmc-10.0.0/tests/test_utilities.py +0 -54
  140. pydtmc-10.0.0/tests/test_validation.py +0 -879
  141. {pydtmc-10.0.0 → pydtmc-11.0.0}/LICENSE.md +0 -0
  142. {pydtmc-10.0.0 → pydtmc-11.0.0}/PyDTMC.egg-info/dependency_links.txt +0 -0
  143. {pydtmc-10.0.0 → pydtmc-11.0.0}/PyDTMC.egg-info/top_level.txt +0 -0
  144. {pydtmc-10.0.0 → pydtmc-11.0.0}/data/empty +0 -0
  145. {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/Makefile +0 -0
  146. {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/build/empty +0 -0
  147. {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/make.bat +0 -0
  148. {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/source/_templates/empty +0 -0
  149. /pydtmc-10.0.0/pydtmc/constants.py → /pydtmc-11.0.0/pydtmc/_constants.py +0 -0
  150. {pydtmc-10.0.0 → pydtmc-11.0.0}/pydtmc/exceptions.py +0 -0
  151. {pydtmc-10.0.0 → pydtmc-11.0.0}/pyproject.toml +0 -0
  152. {pydtmc-10.0.0 → pydtmc-11.0.0}/requirements.txt +0 -0
  153. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/__init__.py +0 -0
  154. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/files/file_empty.txt +0 -0
  155. /pydtmc-10.0.0/tests/files/file_filled.txt → /pydtmc-11.0.0/tests/files/file_noext +0 -0
  156. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_benchmarks.json +0 -0
  157. {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_conversions.json +0 -0
@@ -10,6 +10,7 @@ prune .github
10
10
  prune .idea
11
11
  prune dist
12
12
  prune docs/build
13
+ prune examples
13
14
  prune images
14
15
  global-exclude .env .git* __pycache__ *.dll *.py[cdo] *.so *.yaml *~
15
16
  exclude CODE_OF_CONDUCT.md CONTRIBUTING.md
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyDTMC
3
- Version: 10.0.0
3
+ Version: 11.0.0
4
4
  Summary: Python library for analyzing, simulating, and visualizing discrete-time Markov chains and hidden Markov models.
5
5
  Home-page: https://github.com/TommasoBelluzzo/PyDTMC
6
6
  Author: Tommaso Belluzzo
@@ -56,7 +56,6 @@ Requires-Dist: flake8; extra == "lint"
56
56
  Requires-Dist: pylint; extra == "lint"
57
57
  Provides-Extra: package
58
58
  Requires-Dist: defusedxml; extra == "package"
59
- Requires-Dist: numpydoc; extra == "package"
60
59
  Requires-Dist: pandas; extra == "package"
61
60
  Requires-Dist: pydot; extra == "package"
62
61
  Provides-Extra: tests
@@ -84,7 +83,7 @@ PyDTMC is a lightweight Python library focused on discrete-time Markov chains an
84
83
  <td align="right">Info:</td>
85
84
  <td align="left">
86
85
  <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>
86
+ <a href="https://doi.org/10.5281/zenodo.23423407"><img alt="DOI" src="https://zenodo.org/badge/DOI/10.5281/zenodo.23423407.svg"/></a>
88
87
  <a href="#"><img alt="Size" src="https://img.shields.io/github/repo-size/TommasoBelluzzo/PyDTMC?style=flat&label=Size&color=1081C2"/></a>
89
88
  </td>
90
89
  </tr>
@@ -106,12 +105,6 @@ PyDTMC is a lightweight Python library focused on discrete-time Markov chains an
106
105
  <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
106
  </td>
108
107
  </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
108
  </table>
116
109
 
117
110
  ## Installation
@@ -138,6 +131,13 @@ pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
138
131
 
139
132
  **Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
140
133
 
134
+ ## Resources
135
+
136
+ For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
137
+
138
+ If you use PyDTMC in your work, please cite the software using its [Zenodo DOI](https://doi.org/10.5281/zenodo.23423407).\
139
+ Citation metadata is also available in the [CITATION.cff](https://github.com/TommasoBelluzzo/PyDTMC/blob/master/CITATION.cff) file.
140
+
141
141
  ## Quick Start
142
142
 
143
143
  Import the classes from PyDTMC and create instances of a discrete-time Markov chain and a hidden Markov model:
@@ -196,18 +196,18 @@ print(mc.entropy_rate)
196
196
  print(mc.absorption_probabilities())
197
197
  print(mc.expected_rewards(10, [2.0, -3.0, 8.0, -7.0]))
198
198
  print(mc.expected_transitions(2))
199
+ print(mc.expected_visits())
199
200
  print(mc.first_passage_probabilities(5, 3))
200
201
  print(mc.hitting_probabilities([0, 1]))
201
- print(mc.mean_number_visits())
202
202
  print(mc.simulate(10, seed=32))
203
203
  ```
204
204
 
205
205
  **Visualization**
206
206
 
207
207
  ```python
208
- from pydtmc import plot_eigenvalues, plot_graph, plot_redistributions, plot_sequence, plot_trellis
208
+ from pydtmc import plot_graph, plot_redistributions, plot_sequence, plot_spectrum
209
209
 
210
- plot_eigenvalues(mc, dpi=300)
210
+ plot_spectrum(mc, dpi=300)
211
211
  plot_graph(mc, dpi=300)
212
212
  plot_sequence(mc, 10, plot_type='histogram', dpi=300)
213
213
  plot_sequence(mc, 10, plot_type='heatmap', dpi=300)
@@ -236,7 +236,7 @@ print(hmm.pi)
236
236
  print(hmm.emission_probability('H1', 'A'))
237
237
  print(hmm.transition_probability('A', 'B'))
238
238
  print(hmm.decode(['H1', 'H2', 'H3']))
239
- print(hmm.predict('viterbi', ['H1', 'H2', 'H3']))
239
+ print(hmm.predict('vit', ['H1', 'H2', 'H3']))
240
240
  print(hmm.simulate(12, seed=1488))
241
241
  ```
242
242
 
@@ -253,9 +253,3 @@ plot_trellis(hmm, 10, dpi=300)
253
253
  ```
254
254
 
255
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,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyDTMC
3
- Version: 10.0.0
3
+ Version: 11.0.0
4
4
  Summary: Python library for analyzing, simulating, and visualizing discrete-time Markov chains and hidden Markov models.
5
5
  Home-page: https://github.com/TommasoBelluzzo/PyDTMC
6
6
  Author: Tommaso Belluzzo
@@ -56,7 +56,6 @@ Requires-Dist: flake8; extra == "lint"
56
56
  Requires-Dist: pylint; extra == "lint"
57
57
  Provides-Extra: package
58
58
  Requires-Dist: defusedxml; extra == "package"
59
- Requires-Dist: numpydoc; extra == "package"
60
59
  Requires-Dist: pandas; extra == "package"
61
60
  Requires-Dist: pydot; extra == "package"
62
61
  Provides-Extra: tests
@@ -84,7 +83,7 @@ PyDTMC is a lightweight Python library focused on discrete-time Markov chains an
84
83
  <td align="right">Info:</td>
85
84
  <td align="left">
86
85
  <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>
86
+ <a href="https://doi.org/10.5281/zenodo.23423407"><img alt="DOI" src="https://zenodo.org/badge/DOI/10.5281/zenodo.23423407.svg"/></a>
88
87
  <a href="#"><img alt="Size" src="https://img.shields.io/github/repo-size/TommasoBelluzzo/PyDTMC?style=flat&label=Size&color=1081C2"/></a>
89
88
  </td>
90
89
  </tr>
@@ -106,12 +105,6 @@ PyDTMC is a lightweight Python library focused on discrete-time Markov chains an
106
105
  <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
106
  </td>
108
107
  </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
108
  </table>
116
109
 
117
110
  ## Installation
@@ -138,6 +131,13 @@ pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
138
131
 
139
132
  **Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
140
133
 
134
+ ## Resources
135
+
136
+ For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
137
+
138
+ If you use PyDTMC in your work, please cite the software using its [Zenodo DOI](https://doi.org/10.5281/zenodo.23423407).\
139
+ Citation metadata is also available in the [CITATION.cff](https://github.com/TommasoBelluzzo/PyDTMC/blob/master/CITATION.cff) file.
140
+
141
141
  ## Quick Start
142
142
 
143
143
  Import the classes from PyDTMC and create instances of a discrete-time Markov chain and a hidden Markov model:
@@ -196,18 +196,18 @@ print(mc.entropy_rate)
196
196
  print(mc.absorption_probabilities())
197
197
  print(mc.expected_rewards(10, [2.0, -3.0, 8.0, -7.0]))
198
198
  print(mc.expected_transitions(2))
199
+ print(mc.expected_visits())
199
200
  print(mc.first_passage_probabilities(5, 3))
200
201
  print(mc.hitting_probabilities([0, 1]))
201
- print(mc.mean_number_visits())
202
202
  print(mc.simulate(10, seed=32))
203
203
  ```
204
204
 
205
205
  **Visualization**
206
206
 
207
207
  ```python
208
- from pydtmc import plot_eigenvalues, plot_graph, plot_redistributions, plot_sequence, plot_trellis
208
+ from pydtmc import plot_graph, plot_redistributions, plot_sequence, plot_spectrum
209
209
 
210
- plot_eigenvalues(mc, dpi=300)
210
+ plot_spectrum(mc, dpi=300)
211
211
  plot_graph(mc, dpi=300)
212
212
  plot_sequence(mc, 10, plot_type='histogram', dpi=300)
213
213
  plot_sequence(mc, 10, plot_type='heatmap', dpi=300)
@@ -236,7 +236,7 @@ print(hmm.pi)
236
236
  print(hmm.emission_probability('H1', 'A'))
237
237
  print(hmm.transition_probability('A', 'B'))
238
238
  print(hmm.decode(['H1', 'H2', 'H3']))
239
- print(hmm.predict('viterbi', ['H1', 'H2', 'H3']))
239
+ print(hmm.predict('vit', ['H1', 'H2', 'H3']))
240
240
  print(hmm.simulate(12, seed=1488))
241
241
  ```
242
242
 
@@ -253,9 +253,3 @@ plot_trellis(hmm, 10, dpi=300)
253
253
  ```
254
254
 
255
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,123 @@
1
+ LICENSE.md
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ requirements.txt
6
+ setup.cfg
7
+ setup.py
8
+ PyDTMC.egg-info/PKG-INFO
9
+ PyDTMC.egg-info/SOURCES.txt
10
+ PyDTMC.egg-info/dependency_links.txt
11
+ PyDTMC.egg-info/requires.txt
12
+ PyDTMC.egg-info/top_level.txt
13
+ data/empty
14
+ docs/Makefile
15
+ docs/make.bat
16
+ docs/build/empty
17
+ docs/source/conf.py
18
+ docs/source/genindex.rst
19
+ docs/source/index.rst
20
+ docs/source/_static/css/style.css
21
+ docs/source/_templates/empty
22
+ docs/source/advanced_topics/absorbing_markov_chains.rst
23
+ docs/source/advanced_topics/assessments.rst
24
+ docs/source/advanced_topics/chain_comparison.rst
25
+ docs/source/advanced_topics/hidden_markov_models.rst
26
+ docs/source/advanced_topics/hitting_passage.rst
27
+ docs/source/advanced_topics/index.rst
28
+ docs/source/advanced_topics/long_term_behavior.rst
29
+ docs/source/advanced_topics/markov_chain_analysis.rst
30
+ docs/source/advanced_topics/mixing_convergence.rst
31
+ docs/source/advanced_topics/reduction_aggregation.rst
32
+ docs/source/advanced_topics/simulation_empirical_analysis.rst
33
+ docs/source/advanced_topics/transition_paths_analysis.rst
34
+ docs/source/advanced_topics/visualization.rst
35
+ docs/source/api_reference/custom_exceptions.rst
36
+ docs/source/api_reference/hidden_markov_model.rst
37
+ docs/source/api_reference/hidden_markov_model_methods_instance.rst
38
+ docs/source/api_reference/hidden_markov_model_methods_static.rst
39
+ docs/source/api_reference/hidden_markov_model_properties.rst
40
+ docs/source/api_reference/index.rst
41
+ docs/source/api_reference/markov_chain.rst
42
+ docs/source/api_reference/markov_chain_methods_instance.rst
43
+ docs/source/api_reference/markov_chain_methods_static.rst
44
+ docs/source/api_reference/markov_chain_properties.rst
45
+ docs/source/api_reference/other_assessment_functions.rst
46
+ docs/source/api_reference/other_comparison_functions.rst
47
+ docs/source/api_reference/other_plotting_functions.rst
48
+ docs/source/getting_started/first_hidden_markov_model.rst
49
+ docs/source/getting_started/first_markov_chain.rst
50
+ docs/source/getting_started/index.rst
51
+ docs/source/getting_started/installation.rst
52
+ pydtmc/__init__.py
53
+ pydtmc/_analysis.py
54
+ pydtmc/_base_classes.py
55
+ pydtmc/_constants.py
56
+ pydtmc/_custom_types.py
57
+ pydtmc/_decorators.py
58
+ pydtmc/_dynamics.py
59
+ pydtmc/_files_io.py
60
+ pydtmc/_fitting.py
61
+ pydtmc/_generators.py
62
+ pydtmc/_numerical.py
63
+ pydtmc/_rendering.py
64
+ pydtmc/_utilities.py
65
+ pydtmc/_validation.py
66
+ pydtmc/assessments.py
67
+ pydtmc/comparisons.py
68
+ pydtmc/exceptions.py
69
+ pydtmc/hidden_markov_model.py
70
+ pydtmc/markov_chain.py
71
+ pydtmc/plotting.py
72
+ tests/__init__.py
73
+ tests/benchmarks.py
74
+ tests/conftest.py
75
+ tests/test_aliases.py
76
+ tests/test_assessments.py
77
+ tests/test_comparisons.py
78
+ tests/test_conversions.py
79
+ tests/test_decorators.py
80
+ tests/test_hmm_classification.py
81
+ tests/test_hmm_dynamics.py
82
+ tests/test_hmm_fitting.py
83
+ tests/test_hmm_generators_instance.py
84
+ tests/test_hmm_generators_static.py
85
+ tests/test_hmm_measures.py
86
+ tests/test_hmm_properties.py
87
+ tests/test_mc_classification.py
88
+ tests/test_mc_dynamics.py
89
+ tests/test_mc_fitting.py
90
+ tests/test_mc_generators_instance.py
91
+ tests/test_mc_generators_static.py
92
+ tests/test_mc_measures.py
93
+ tests/test_mc_properties.py
94
+ tests/test_plotting.py
95
+ tests/test_utilities.py
96
+ tests/test_validation.py
97
+ tests/utilities.py
98
+ tests/files/file_empty.txt
99
+ tests/files/file_filled.txt
100
+ tests/files/file_noext
101
+ tests/fixtures/fixtures_aliases.json
102
+ tests/fixtures/fixtures_assessments.json
103
+ tests/fixtures/fixtures_benchmarks.json
104
+ tests/fixtures/fixtures_comparisons.json
105
+ tests/fixtures/fixtures_conversions.json
106
+ tests/fixtures/fixtures_hmm.json
107
+ tests/fixtures/fixtures_hmm_classification.json
108
+ tests/fixtures/fixtures_hmm_dynamics.json
109
+ tests/fixtures/fixtures_hmm_fitting.json
110
+ tests/fixtures/fixtures_hmm_generators_instance.json
111
+ tests/fixtures/fixtures_hmm_generators_static.json
112
+ tests/fixtures/fixtures_hmm_measures.json
113
+ tests/fixtures/fixtures_hmm_properties.json
114
+ tests/fixtures/fixtures_mc_classification.json
115
+ tests/fixtures/fixtures_mc_dynamics.json
116
+ tests/fixtures/fixtures_mc_fitting.json
117
+ tests/fixtures/fixtures_mc_generators_instance.json
118
+ tests/fixtures/fixtures_mc_generators_static.json
119
+ tests/fixtures/fixtures_mc_measures.json
120
+ tests/fixtures/fixtures_mc_properties.json
121
+ tests/fixtures/fixtures_plotting.json
122
+ tests/fixtures/fixtures_utilities.json
123
+ tests/fixtures/fixtures_validation.json
@@ -22,7 +22,6 @@ pylint
22
22
 
23
23
  [package]
24
24
  defusedxml
25
- numpydoc
26
25
  pandas
27
26
  pydot
28
27
 
@@ -15,7 +15,7 @@ PyDTMC is a lightweight Python library focused on discrete-time Markov chains an
15
15
  <td align="right">Info:</td>
16
16
  <td align="left">
17
17
  <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>
18
- <a href="https://doi.org/10.5281/zenodo.23363778"><img alt="DOI" src="https://zenodo.org/badge/DOI/10.5281/zenodo.23363778.svg"/></a>
18
+ <a href="https://doi.org/10.5281/zenodo.23423407"><img alt="DOI" src="https://zenodo.org/badge/DOI/10.5281/zenodo.23423407.svg"/></a>
19
19
  <a href="#"><img alt="Size" src="https://img.shields.io/github/repo-size/TommasoBelluzzo/PyDTMC?style=flat&label=Size&color=1081C2"/></a>
20
20
  </td>
21
21
  </tr>
@@ -37,12 +37,6 @@ PyDTMC is a lightweight Python library focused on discrete-time Markov chains an
37
37
  <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>
38
38
  </td>
39
39
  </tr>
40
- <tr>
41
- <td align="right">Donation:</td>
42
- <td align="left">
43
- <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>
44
- </td>
45
- </tr>
46
40
  </table>
47
41
 
48
42
  ## Installation
@@ -69,6 +63,13 @@ pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
69
63
 
70
64
  **Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
71
65
 
66
+ ## Resources
67
+
68
+ For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
69
+
70
+ If you use PyDTMC in your work, please cite the software using its [Zenodo DOI](https://doi.org/10.5281/zenodo.23423407).\
71
+ Citation metadata is also available in the [CITATION.cff](https://github.com/TommasoBelluzzo/PyDTMC/blob/master/CITATION.cff) file.
72
+
72
73
  ## Quick Start
73
74
 
74
75
  Import the classes from PyDTMC and create instances of a discrete-time Markov chain and a hidden Markov model:
@@ -127,18 +128,18 @@ print(mc.entropy_rate)
127
128
  print(mc.absorption_probabilities())
128
129
  print(mc.expected_rewards(10, [2.0, -3.0, 8.0, -7.0]))
129
130
  print(mc.expected_transitions(2))
131
+ print(mc.expected_visits())
130
132
  print(mc.first_passage_probabilities(5, 3))
131
133
  print(mc.hitting_probabilities([0, 1]))
132
- print(mc.mean_number_visits())
133
134
  print(mc.simulate(10, seed=32))
134
135
  ```
135
136
 
136
137
  **Visualization**
137
138
 
138
139
  ```python
139
- from pydtmc import plot_eigenvalues, plot_graph, plot_redistributions, plot_sequence, plot_trellis
140
+ from pydtmc import plot_graph, plot_redistributions, plot_sequence, plot_spectrum
140
141
 
141
- plot_eigenvalues(mc, dpi=300)
142
+ plot_spectrum(mc, dpi=300)
142
143
  plot_graph(mc, dpi=300)
143
144
  plot_sequence(mc, 10, plot_type='histogram', dpi=300)
144
145
  plot_sequence(mc, 10, plot_type='heatmap', dpi=300)
@@ -167,7 +168,7 @@ print(hmm.pi)
167
168
  print(hmm.emission_probability('H1', 'A'))
168
169
  print(hmm.transition_probability('A', 'B'))
169
170
  print(hmm.decode(['H1', 'H2', 'H3']))
170
- print(hmm.predict('viterbi', ['H1', 'H2', 'H3']))
171
+ print(hmm.predict('vit', ['H1', 'H2', 'H3']))
171
172
  print(hmm.simulate(12, seed=1488))
172
173
  ```
173
174
 
@@ -184,9 +185,3 @@ plot_trellis(hmm, 10, dpi=300)
184
185
  ```
185
186
 
186
187
  ![HiddenMarkovModel Plots](https://i.imgur.com/rSNUbdX.gif)
187
-
188
- ## References
189
-
190
- For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
191
-
192
- If you use PyDTMC in your work, please cite the software using its [Zenodo DOI](https://doi.org/10.5281/zenodo.23363778).
@@ -55,6 +55,10 @@
55
55
  margin-bottom: 24px !important;
56
56
  }
57
57
 
58
+ .rst-content dl.py.property > dd > dl.field-list:last-child {
59
+ margin-bottom: 0 !important;
60
+ }
61
+
58
62
  .wy-nav-content {
59
63
  max-width: 1200px !important;
60
64
  }
@@ -0,0 +1,146 @@
1
+ Absorbing Markov Chains
2
+ =======================
3
+
4
+ | This guide explores how a Markov chain can describe a process that eventually reaches a final outcome.
5
+ | The example follows an application through submission, review, approval, or rejection.
6
+
7
+ Model Construction
8
+ ------------------
9
+
10
+ | An application can remain ``Submitted``, move to ``Review``, or be ``Approved`` immediately.
11
+ | During review, it may remain under consideration, be approved, or be rejected.
12
+ | Once approved or rejected, the application does not change status.
13
+
14
+ The transition matrix is:
15
+
16
+ .. math::
17
+
18
+ P = \begin{pmatrix}
19
+ 0.50 & 0.25 & 0.25 & 0.00 \\
20
+ 0.00 & 0.50 & 0.25 & 0.25 \\
21
+ 0.00 & 0.00 & 1.00 & 0.00 \\
22
+ 0.00 & 0.00 & 0.00 & 1.00
23
+ \end{pmatrix}
24
+
25
+ | Rows and columns follow the order ``Submitted``, ``Review``, ``Approved``, and ``Rejected``.
26
+ | For example, an application under review has a 50% chance of remaining under review for another step.
27
+ | It also has a 25% chance of approval and a 25% chance of rejection.
28
+
29
+ Using PyDTMC, the chain can be created as follows:
30
+
31
+ .. code-block:: python
32
+
33
+ from pydtmc import MarkovChain
34
+
35
+ p = [
36
+ [0.50, 0.25, 0.25, 0.00],
37
+ [0.00, 0.50, 0.25, 0.25],
38
+ [0.00, 0.00, 1.00, 0.00],
39
+ [0.00, 0.00, 0.00, 1.00]
40
+ ]
41
+
42
+ mc = MarkovChain(p, ['Submitted', 'Review', 'Approved', 'Rejected'])
43
+
44
+ Absorbing and Transient States
45
+ ------------------------------
46
+
47
+ | An **absorbing state** is a state that cannot be left once entered.
48
+ | Here, ``Approved`` and ``Rejected`` are absorbing states: both have a probability of ``1.0`` of remaining unchanged.
49
+ | A **transient state** is one that the chain may leave without ever returning to it.
50
+ | ``Submitted`` and ``Review`` are transient because the application can eventually reach a final decision.
51
+
52
+ | A chain is **absorbing** when it has at least one absorbing state and every state can reach an absorbing state.
53
+ | In this model, every application eventually reaches approval or rejection with probability 1.
54
+
55
+ These properties can be inspected as follows:
56
+
57
+ .. code-block:: python
58
+
59
+ print(mc.absorbing_states)
60
+ print(mc.transient_states)
61
+ print(mc.is_absorbing)
62
+
63
+ Absorption Probabilities
64
+ ------------------------
65
+
66
+ | Reaching a final decision is certain, but the outcome is not.
67
+ | The **absorption probabilities** describe the chances of eventually reaching each absorbing state.
68
+ | An application under review has equal chances of eventual approval and rejection.
69
+ | A submitted application has a higher chance of approval because it may be approved without entering review.
70
+
71
+ Using PyDTMC, these probabilities can be computed as follows:
72
+
73
+ .. code-block:: python
74
+
75
+ print(mc.absorption_probabilities())
76
+
77
+ The resulting matrix is:
78
+
79
+ .. math::
80
+
81
+ B = \begin{pmatrix}
82
+ 0.75 & 0.50 \\
83
+ 0.25 & 0.50
84
+ \end{pmatrix}
85
+
86
+ | Each row represents an absorbing state, ordered as ``Approved`` and ``Rejected``.
87
+ | Each column represents a transient starting state, ordered as ``Submitted`` and ``Review``.
88
+ | Thus, a submitted application is eventually approved with probability ``0.75`` and rejected with probability ``0.25``.
89
+ | An application already under review has a ``0.50`` probability of either outcome.
90
+
91
+ Expected Absorption Times
92
+ -------------------------
93
+
94
+ | The **absorption time** is the number of transitions needed to reach a final decision.
95
+ | It can vary from one application to another, therefore we calculate its expected value.
96
+
97
+ .. code-block:: python
98
+
99
+ print(mc.absorption_times('mean'))
100
+
101
+ The expected absorption times are:
102
+
103
+ .. math::
104
+
105
+ \mathbf{t} = \begin{pmatrix} 3 \\ 2 \end{pmatrix}
106
+
107
+ | A submitted application takes an average of three transitions to reach a final decision.
108
+ | An application already under review takes an average of two transitions.
109
+
110
+ Occupation Matrix
111
+ -----------------
112
+
113
+ | Before a final decision, an application may spend several steps in a transient state.
114
+ | The **occupation matrix** gives the expected number of visits to each transient state before absorption.
115
+ | It includes the starting state as a visit.
116
+
117
+ .. code-block:: python
118
+
119
+ print(mc.occupation_matrix)
120
+
121
+ For this model, the occupation matrix is:
122
+
123
+ .. math::
124
+
125
+ N = \begin{pmatrix}
126
+ 2 & 1 \\
127
+ 0 & 2
128
+ \end{pmatrix}
129
+
130
+ | Rows represent the starting states and columns represent the states visited, both ordered as ``Submitted`` and ``Review``.
131
+ | Starting from ``Submitted``, an application spends an expected two steps there and one step in ``Review``.
132
+ | Starting from ``Review``, it spends an expected two steps under review and never returns to ``Submitted``.
133
+ | The row sums, ``3`` and ``2``, agree with the expected absorption times calculated above.
134
+
135
+ Simulation
136
+ ----------
137
+
138
+ A simulation generates one possible sequence of application statuses:
139
+
140
+ .. code-block:: python
141
+
142
+ print(mc.simulate(10, initial_state='Submitted', seed=42))
143
+
144
+ | The simulated application may remain in a transient state for several steps before reaching a final decision.
145
+ | Once it reaches ``Approved`` or ``Rejected``, its status cannot change.
146
+ | Unlike the expected absorption times, a simulation shows one possible outcome rather than an average over many applications.