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.
- {pydtmc-10.0.0 → pydtmc-11.0.0}/MANIFEST.in +1 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/PKG-INFO +13 -19
- {pydtmc-10.0.0 → pydtmc-11.0.0}/PyDTMC.egg-info/PKG-INFO +13 -19
- pydtmc-11.0.0/PyDTMC.egg-info/SOURCES.txt +123 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/PyDTMC.egg-info/requires.txt +0 -1
- {pydtmc-10.0.0 → pydtmc-11.0.0}/README.md +12 -17
- {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/source/_static/css/style.css +4 -0
- pydtmc-11.0.0/docs/source/advanced_topics/absorbing_markov_chains.rst +146 -0
- pydtmc-11.0.0/docs/source/advanced_topics/assessments.rst +214 -0
- pydtmc-11.0.0/docs/source/advanced_topics/chain_comparison.rst +155 -0
- pydtmc-11.0.0/docs/source/advanced_topics/hidden_markov_models.rst +159 -0
- pydtmc-11.0.0/docs/source/advanced_topics/hitting_passage.rst +145 -0
- pydtmc-11.0.0/docs/source/advanced_topics/index.rst +21 -0
- pydtmc-11.0.0/docs/source/advanced_topics/long_term_behavior.rst +138 -0
- pydtmc-11.0.0/docs/source/advanced_topics/markov_chain_analysis.rst +146 -0
- pydtmc-11.0.0/docs/source/advanced_topics/mixing_convergence.rst +203 -0
- pydtmc-11.0.0/docs/source/advanced_topics/reduction_aggregation.rst +139 -0
- pydtmc-11.0.0/docs/source/advanced_topics/simulation_empirical_analysis.rst +132 -0
- pydtmc-11.0.0/docs/source/advanced_topics/transition_paths_analysis.rst +131 -0
- pydtmc-11.0.0/docs/source/advanced_topics/visualization.rst +152 -0
- {pydtmc-10.0.0/docs/source → pydtmc-11.0.0/docs/source/api_reference}/custom_exceptions.rst +5 -5
- pydtmc-11.0.0/docs/source/api_reference/hidden_markov_model.rst +15 -0
- pydtmc-11.0.0/docs/source/api_reference/hidden_markov_model_methods_instance.rst +36 -0
- pydtmc-11.0.0/docs/source/api_reference/hidden_markov_model_methods_static.rst +18 -0
- pydtmc-11.0.0/docs/source/api_reference/hidden_markov_model_properties.rst +23 -0
- pydtmc-11.0.0/docs/source/api_reference/index.rst +19 -0
- pydtmc-11.0.0/docs/source/api_reference/markov_chain.rst +14 -0
- pydtmc-11.0.0/docs/source/api_reference/markov_chain_methods_instance.rst +76 -0
- pydtmc-11.0.0/docs/source/api_reference/markov_chain_methods_static.rst +34 -0
- pydtmc-11.0.0/docs/source/api_reference/markov_chain_properties.rst +65 -0
- {pydtmc-10.0.0/docs/source → pydtmc-11.0.0/docs/source/api_reference}/other_assessment_functions.rst +3 -1
- {pydtmc-10.0.0/docs/source → pydtmc-11.0.0/docs/source/api_reference}/other_comparison_functions.rst +2 -0
- {pydtmc-10.0.0/docs/source → pydtmc-11.0.0/docs/source/api_reference}/other_plotting_functions.rst +7 -2
- {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/source/conf.py +76 -4
- {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/source/genindex.rst +1 -1
- pydtmc-11.0.0/docs/source/getting_started/first_hidden_markov_model.rst +52 -0
- pydtmc-11.0.0/docs/source/getting_started/first_markov_chain.rst +57 -0
- pydtmc-11.0.0/docs/source/getting_started/index.rst +11 -0
- pydtmc-11.0.0/docs/source/getting_started/installation.rst +27 -0
- pydtmc-11.0.0/docs/source/index.rst +17 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/pydtmc/__init__.py +20 -4
- pydtmc-11.0.0/pydtmc/_analysis.py +2572 -0
- pydtmc-10.0.0/pydtmc/base_classes.py → pydtmc-11.0.0/pydtmc/_base_classes.py +4 -8
- pydtmc-11.0.0/pydtmc/_custom_types.py +466 -0
- pydtmc-10.0.0/pydtmc/decorators.py → pydtmc-11.0.0/pydtmc/_decorators.py +7 -7
- pydtmc-11.0.0/pydtmc/_dynamics.py +388 -0
- pydtmc-10.0.0/pydtmc/files_io.py → pydtmc-11.0.0/pydtmc/_files_io.py +17 -19
- pydtmc-11.0.0/pydtmc/_fitting.py +462 -0
- pydtmc-11.0.0/pydtmc/_generators.py +2135 -0
- pydtmc-11.0.0/pydtmc/_numerical.py +599 -0
- pydtmc-11.0.0/pydtmc/_rendering.py +2152 -0
- pydtmc-10.0.0/pydtmc/utilities.py → pydtmc-11.0.0/pydtmc/_utilities.py +70 -85
- pydtmc-10.0.0/pydtmc/validation.py → pydtmc-11.0.0/pydtmc/_validation.py +529 -371
- {pydtmc-10.0.0 → pydtmc-11.0.0}/pydtmc/assessments.py +286 -126
- pydtmc-11.0.0/pydtmc/comparisons.py +332 -0
- pydtmc-11.0.0/pydtmc/hidden_markov_model.py +1706 -0
- pydtmc-11.0.0/pydtmc/markov_chain.py +4480 -0
- pydtmc-11.0.0/pydtmc/plotting.py +535 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/setup.cfg +6 -8
- {pydtmc-10.0.0 → pydtmc-11.0.0}/setup.py +2 -2
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/benchmarks.py +3 -3
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/conftest.py +28 -20
- pydtmc-11.0.0/tests/files/file_filled.txt +1 -0
- pydtmc-11.0.0/tests/fixtures/fixtures_aliases.json +279 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_assessments.json +327 -127
- pydtmc-11.0.0/tests/fixtures/fixtures_comparisons.json +802 -0
- pydtmc-11.0.0/tests/fixtures/fixtures_hmm.json +5548 -0
- pydtmc-11.0.0/tests/fixtures/fixtures_hmm_classification.json +150 -0
- pydtmc-11.0.0/tests/fixtures/fixtures_hmm_dynamics.json +2537 -0
- pydtmc-11.0.0/tests/fixtures/fixtures_hmm_fitting.json +617 -0
- pydtmc-11.0.0/tests/fixtures/fixtures_hmm_generators_instance.json +329 -0
- pydtmc-11.0.0/tests/fixtures/fixtures_hmm_generators_static.json +795 -0
- pydtmc-11.0.0/tests/fixtures/fixtures_hmm_measures.json +1810 -0
- pydtmc-11.0.0/tests/fixtures/fixtures_hmm_properties.json +444 -0
- pydtmc-11.0.0/tests/fixtures/fixtures_mc_classification.json +208 -0
- pydtmc-10.0.0/tests/fixtures/fixtures_simulations.json → pydtmc-11.0.0/tests/fixtures/fixtures_mc_dynamics.json +671 -167
- pydtmc-11.0.0/tests/fixtures/fixtures_mc_fitting.json +420 -0
- pydtmc-10.0.0/tests/fixtures/fixtures_generators_instance.json → pydtmc-11.0.0/tests/fixtures/fixtures_mc_generators_instance.json +866 -0
- pydtmc-10.0.0/tests/fixtures/fixtures_generators_static.json → pydtmc-11.0.0/tests/fixtures/fixtures_mc_generators_static.json +1193 -135
- pydtmc-11.0.0/tests/fixtures/fixtures_mc_measures.json +8114 -0
- pydtmc-10.0.0/tests/fixtures/fixtures_properties.json → pydtmc-11.0.0/tests/fixtures/fixtures_mc_properties.json +506 -1
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_plotting.json +29 -4
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_utilities.json +107 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_validation.json +3575 -1430
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/test_aliases.py +97 -6
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/test_assessments.py +44 -24
- pydtmc-11.0.0/tests/test_comparisons.py +142 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/test_conversions.py +7 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/test_decorators.py +27 -2
- pydtmc-11.0.0/tests/test_hmm_classification.py +26 -0
- pydtmc-11.0.0/tests/test_hmm_dynamics.py +257 -0
- pydtmc-11.0.0/tests/test_hmm_fitting.py +228 -0
- pydtmc-11.0.0/tests/test_hmm_generators_instance.py +57 -0
- pydtmc-11.0.0/tests/test_hmm_generators_static.py +141 -0
- pydtmc-11.0.0/tests/test_hmm_measures.py +174 -0
- pydtmc-11.0.0/tests/test_hmm_properties.py +145 -0
- pydtmc-10.0.0/tests/test_classification.py → pydtmc-11.0.0/tests/test_mc_classification.py +24 -0
- pydtmc-10.0.0/tests/test_simulations.py → pydtmc-11.0.0/tests/test_mc_dynamics.py +26 -8
- pydtmc-10.0.0/tests/test_fitting.py → pydtmc-11.0.0/tests/test_mc_fitting.py +8 -2
- pydtmc-11.0.0/tests/test_mc_generators_instance.py +482 -0
- pydtmc-11.0.0/tests/test_mc_generators_static.py +338 -0
- pydtmc-10.0.0/tests/test_measures.py → pydtmc-11.0.0/tests/test_mc_measures.py +176 -31
- pydtmc-10.0.0/tests/test_properties.py → pydtmc-11.0.0/tests/test_mc_properties.py +112 -23
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/test_plotting.py +118 -110
- pydtmc-11.0.0/tests/test_utilities.py +206 -0
- pydtmc-11.0.0/tests/test_validation.py +690 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/utilities.py +20 -2
- pydtmc-10.0.0/PyDTMC.egg-info/SOURCES.txt +0 -91
- pydtmc-10.0.0/docs/source/hidden_markov_model.rst +0 -15
- pydtmc-10.0.0/docs/source/hidden_markov_model_methods_instance.rst +0 -19
- pydtmc-10.0.0/docs/source/hidden_markov_model_methods_static.rst +0 -15
- pydtmc-10.0.0/docs/source/hidden_markov_model_properties.rst +0 -18
- pydtmc-10.0.0/docs/source/index.rst +0 -20
- pydtmc-10.0.0/docs/source/markov_chain.rst +0 -15
- pydtmc-10.0.0/docs/source/markov_chain_methods_instance.rst +0 -63
- pydtmc-10.0.0/docs/source/markov_chain_methods_static.rst +0 -23
- pydtmc-10.0.0/docs/source/markov_chain_properties.rst +0 -61
- pydtmc-10.0.0/pydtmc/comparisons.py +0 -195
- pydtmc-10.0.0/pydtmc/computations.py +0 -270
- pydtmc-10.0.0/pydtmc/custom_types.py +0 -366
- pydtmc-10.0.0/pydtmc/fitting.py +0 -317
- pydtmc-10.0.0/pydtmc/generators.py +0 -1312
- pydtmc-10.0.0/pydtmc/hidden_markov_model.py +0 -988
- pydtmc-10.0.0/pydtmc/markov_chain.py +0 -3980
- pydtmc-10.0.0/pydtmc/measures.py +0 -997
- pydtmc-10.0.0/pydtmc/plotting.py +0 -1633
- pydtmc-10.0.0/pydtmc/simulations.py +0 -284
- pydtmc-10.0.0/tests/files/file_noextension +0 -0
- pydtmc-10.0.0/tests/fixtures/fixtures_aliases.json +0 -105
- pydtmc-10.0.0/tests/fixtures/fixtures_classification.json +0 -92
- pydtmc-10.0.0/tests/fixtures/fixtures_comparisons.json +0 -407
- pydtmc-10.0.0/tests/fixtures/fixtures_fitting.json +0 -160
- pydtmc-10.0.0/tests/fixtures/fixtures_hmm.json +0 -1765
- pydtmc-10.0.0/tests/fixtures/fixtures_measures.json +0 -3599
- pydtmc-10.0.0/tests/test_comparisons.py +0 -84
- pydtmc-10.0.0/tests/test_generators_instance.py +0 -276
- pydtmc-10.0.0/tests/test_generators_static.py +0 -138
- pydtmc-10.0.0/tests/test_hmm.py +0 -285
- pydtmc-10.0.0/tests/test_utilities.py +0 -54
- pydtmc-10.0.0/tests/test_validation.py +0 -879
- {pydtmc-10.0.0 → pydtmc-11.0.0}/LICENSE.md +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/PyDTMC.egg-info/dependency_links.txt +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/PyDTMC.egg-info/top_level.txt +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/data/empty +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/Makefile +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/build/empty +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/make.bat +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/docs/source/_templates/empty +0 -0
- /pydtmc-10.0.0/pydtmc/constants.py → /pydtmc-11.0.0/pydtmc/_constants.py +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/pydtmc/exceptions.py +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/pyproject.toml +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/requirements.txt +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/__init__.py +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/files/file_empty.txt +0 -0
- /pydtmc-10.0.0/tests/files/file_filled.txt → /pydtmc-11.0.0/tests/files/file_noext +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_benchmarks.json +0 -0
- {pydtmc-10.0.0 → pydtmc-11.0.0}/tests/fixtures/fixtures_conversions.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyDTMC
|
|
3
|
-
Version:
|
|
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.
|
|
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
|
|
208
|
+
from pydtmc import plot_graph, plot_redistributions, plot_sequence, plot_spectrum
|
|
209
209
|
|
|
210
|
-
|
|
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('
|
|
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
|

|
|
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:
|
|
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.
|
|
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
|
|
208
|
+
from pydtmc import plot_graph, plot_redistributions, plot_sequence, plot_spectrum
|
|
209
209
|
|
|
210
|
-
|
|
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('
|
|
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
|

|
|
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
|
|
@@ -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.
|
|
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
|
|
140
|
+
from pydtmc import plot_graph, plot_redistributions, plot_sequence, plot_spectrum
|
|
140
141
|
|
|
141
|
-
|
|
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('
|
|
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
|

|
|
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).
|
|
@@ -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.
|