PyDTMC 10.0.0__tar.gz → 10.1.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-10.1.0}/MANIFEST.in +1 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/PKG-INFO +8 -7
- {pydtmc-10.0.0 → pydtmc-10.1.0}/PyDTMC.egg-info/PKG-INFO +8 -7
- pydtmc-10.1.0/PyDTMC.egg-info/SOURCES.txt +109 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/README.md +7 -6
- {pydtmc-10.0.0 → pydtmc-10.1.0}/docs/source/_static/css/style.css +4 -0
- pydtmc-10.1.0/docs/source/advanced_topics/absorbing_markov_chains.rst +146 -0
- pydtmc-10.1.0/docs/source/advanced_topics/assessments.rst +214 -0
- pydtmc-10.1.0/docs/source/advanced_topics/chain_comparison.rst +155 -0
- pydtmc-10.1.0/docs/source/advanced_topics/hidden_markov_models.rst +159 -0
- pydtmc-10.1.0/docs/source/advanced_topics/hitting_passage.rst +149 -0
- pydtmc-10.1.0/docs/source/advanced_topics/index.rst +21 -0
- pydtmc-10.1.0/docs/source/advanced_topics/long_term_behavior.rst +138 -0
- pydtmc-10.1.0/docs/source/advanced_topics/markov_chain_analysis.rst +146 -0
- pydtmc-10.1.0/docs/source/advanced_topics/mixing_convergence.rst +203 -0
- pydtmc-10.1.0/docs/source/advanced_topics/reduction_aggregation.rst +139 -0
- pydtmc-10.1.0/docs/source/advanced_topics/simulation_empirical_analysis.rst +132 -0
- pydtmc-10.1.0/docs/source/advanced_topics/transition_paths_analysis.rst +131 -0
- pydtmc-10.1.0/docs/source/advanced_topics/visualization.rst +152 -0
- {pydtmc-10.0.0/docs/source → pydtmc-10.1.0/docs/source/api_reference}/custom_exceptions.rst +5 -5
- pydtmc-10.1.0/docs/source/api_reference/hidden_markov_model.rst +15 -0
- pydtmc-10.1.0/docs/source/api_reference/hidden_markov_model_methods_instance.rst +28 -0
- pydtmc-10.1.0/docs/source/api_reference/hidden_markov_model_methods_static.rst +15 -0
- pydtmc-10.1.0/docs/source/api_reference/hidden_markov_model_properties.rst +20 -0
- pydtmc-10.1.0/docs/source/api_reference/index.rst +15 -0
- pydtmc-10.1.0/docs/source/api_reference/markov_chain.rst +14 -0
- pydtmc-10.1.0/docs/source/api_reference/markov_chain_methods_instance.rst +66 -0
- pydtmc-10.1.0/docs/source/api_reference/markov_chain_methods_static.rst +23 -0
- pydtmc-10.1.0/docs/source/api_reference/markov_chain_properties.rst +62 -0
- {pydtmc-10.0.0/docs/source → pydtmc-10.1.0/docs/source/api_reference}/other_assessment_functions.rst +2 -1
- {pydtmc-10.0.0/docs/source → pydtmc-10.1.0/docs/source/api_reference}/other_plotting_functions.rst +2 -1
- {pydtmc-10.0.0 → pydtmc-10.1.0}/docs/source/conf.py +76 -1
- {pydtmc-10.0.0 → pydtmc-10.1.0}/docs/source/genindex.rst +1 -1
- pydtmc-10.1.0/docs/source/getting_started/first_hidden_markov_model.rst +52 -0
- pydtmc-10.1.0/docs/source/getting_started/first_markov_chain.rst +57 -0
- pydtmc-10.1.0/docs/source/getting_started/index.rst +11 -0
- pydtmc-10.1.0/docs/source/getting_started/installation.rst +27 -0
- pydtmc-10.1.0/docs/source/index.rst +17 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/pydtmc/__init__.py +4 -2
- pydtmc-10.0.0/pydtmc/measures.py → pydtmc-10.1.0/pydtmc/_analysis.py +995 -292
- pydtmc-10.0.0/pydtmc/base_classes.py → pydtmc-10.1.0/pydtmc/_base_classes.py +1 -1
- pydtmc-10.0.0/pydtmc/custom_types.py → pydtmc-10.1.0/pydtmc/_custom_types.py +33 -13
- pydtmc-10.0.0/pydtmc/decorators.py → pydtmc-10.1.0/pydtmc/_decorators.py +1 -1
- pydtmc-10.0.0/pydtmc/simulations.py → pydtmc-10.1.0/pydtmc/_dynamics.py +164 -52
- pydtmc-10.0.0/pydtmc/files_io.py → pydtmc-10.1.0/pydtmc/_files_io.py +1 -1
- pydtmc-10.1.0/pydtmc/_fitting.py +486 -0
- pydtmc-10.0.0/pydtmc/generators.py → pydtmc-10.1.0/pydtmc/_generators.py +800 -677
- pydtmc-10.1.0/pydtmc/_numerical.py +408 -0
- pydtmc-10.0.0/pydtmc/utilities.py → pydtmc-10.1.0/pydtmc/_utilities.py +2 -2
- pydtmc-10.0.0/pydtmc/validation.py → pydtmc-10.1.0/pydtmc/_validation.py +89 -34
- {pydtmc-10.0.0 → pydtmc-10.1.0}/pydtmc/assessments.py +132 -24
- {pydtmc-10.0.0 → pydtmc-10.1.0}/pydtmc/comparisons.py +6 -6
- pydtmc-10.1.0/pydtmc/hidden_markov_model.py +1445 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/pydtmc/markov_chain.py +462 -670
- {pydtmc-10.0.0 → pydtmc-10.1.0}/pydtmc/plotting.py +32 -31
- pydtmc-10.1.0/tests/files/file_filled.txt +1 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_assessments.json +108 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_comparisons.json +5 -5
- pydtmc-10.0.0/tests/fixtures/fixtures_simulations.json → pydtmc-10.1.0/tests/fixtures/fixtures_dynamics.json +130 -10
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_fitting.json +56 -0
- pydtmc-10.1.0/tests/fixtures/fixtures_hmm.json +3371 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_measures.json +50 -26
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_validation.json +212 -78
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_aliases.py +2 -2
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_assessments.py +12 -1
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_decorators.py +1 -1
- pydtmc-10.0.0/tests/test_simulations.py → pydtmc-10.1.0/tests/test_dynamics.py +23 -5
- pydtmc-10.1.0/tests/test_hmm.py +595 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_measures.py +6 -10
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_properties.py +7 -9
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_utilities.py +2 -1
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_validation.py +80 -37
- 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/computations.py +0 -270
- pydtmc-10.0.0/pydtmc/fitting.py +0 -317
- pydtmc-10.0.0/pydtmc/hidden_markov_model.py +0 -988
- pydtmc-10.0.0/tests/files/file_noextension +0 -0
- pydtmc-10.0.0/tests/fixtures/fixtures_hmm.json +0 -1765
- pydtmc-10.0.0/tests/test_hmm.py +0 -285
- {pydtmc-10.0.0 → pydtmc-10.1.0}/LICENSE.md +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/PyDTMC.egg-info/dependency_links.txt +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/PyDTMC.egg-info/requires.txt +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/PyDTMC.egg-info/top_level.txt +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/data/empty +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/docs/Makefile +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/docs/build/empty +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/docs/make.bat +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/docs/source/_templates/empty +0 -0
- {pydtmc-10.0.0/docs/source → pydtmc-10.1.0/docs/source/api_reference}/other_comparison_functions.rst +0 -0
- /pydtmc-10.0.0/pydtmc/constants.py → /pydtmc-10.1.0/pydtmc/_constants.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/pydtmc/exceptions.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/pyproject.toml +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/requirements.txt +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/setup.cfg +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/setup.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/__init__.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/benchmarks.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/conftest.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/files/file_empty.txt +0 -0
- /pydtmc-10.0.0/tests/files/file_filled.txt → /pydtmc-10.1.0/tests/files/file_noext +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_aliases.json +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_benchmarks.json +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_classification.json +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_conversions.json +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_generators_instance.json +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_generators_static.json +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_plotting.json +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_properties.json +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/fixtures/fixtures_utilities.json +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_classification.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_comparisons.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_conversions.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_fitting.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_generators_instance.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_generators_static.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/test_plotting.py +0 -0
- {pydtmc-10.0.0 → pydtmc-10.1.0}/tests/utilities.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyDTMC
|
|
3
|
-
Version: 10.
|
|
3
|
+
Version: 10.1.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
|
|
@@ -138,6 +138,13 @@ pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
|
|
|
138
138
|
|
|
139
139
|
**Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
|
|
140
140
|
|
|
141
|
+
## Resources
|
|
142
|
+
|
|
143
|
+
For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
|
|
144
|
+
|
|
145
|
+
If you use PyDTMC in your work, please cite the software using its [Zenodo DOI](https://doi.org/10.5281/zenodo.23363778).\
|
|
146
|
+
Citation metadata is also available in the [CITATION.cff](https://github.com/TommasoBelluzzo/PyDTMC/blob/master/CITATION.cff) file.
|
|
147
|
+
|
|
141
148
|
## Quick Start
|
|
142
149
|
|
|
143
150
|
Import the classes from PyDTMC and create instances of a discrete-time Markov chain and a hidden Markov model:
|
|
@@ -253,9 +260,3 @@ plot_trellis(hmm, 10, dpi=300)
|
|
|
253
260
|
```
|
|
254
261
|
|
|
255
262
|

|
|
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.
|
|
3
|
+
Version: 10.1.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
|
|
@@ -138,6 +138,13 @@ pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
|
|
|
138
138
|
|
|
139
139
|
**Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
|
|
140
140
|
|
|
141
|
+
## Resources
|
|
142
|
+
|
|
143
|
+
For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
|
|
144
|
+
|
|
145
|
+
If you use PyDTMC in your work, please cite the software using its [Zenodo DOI](https://doi.org/10.5281/zenodo.23363778).\
|
|
146
|
+
Citation metadata is also available in the [CITATION.cff](https://github.com/TommasoBelluzzo/PyDTMC/blob/master/CITATION.cff) file.
|
|
147
|
+
|
|
141
148
|
## Quick Start
|
|
142
149
|
|
|
143
150
|
Import the classes from PyDTMC and create instances of a discrete-time Markov chain and a hidden Markov model:
|
|
@@ -253,9 +260,3 @@ plot_trellis(hmm, 10, dpi=300)
|
|
|
253
260
|
```
|
|
254
261
|
|
|
255
262
|

|
|
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,109 @@
|
|
|
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/_utilities.py
|
|
64
|
+
pydtmc/_validation.py
|
|
65
|
+
pydtmc/assessments.py
|
|
66
|
+
pydtmc/comparisons.py
|
|
67
|
+
pydtmc/exceptions.py
|
|
68
|
+
pydtmc/hidden_markov_model.py
|
|
69
|
+
pydtmc/markov_chain.py
|
|
70
|
+
pydtmc/plotting.py
|
|
71
|
+
tests/__init__.py
|
|
72
|
+
tests/benchmarks.py
|
|
73
|
+
tests/conftest.py
|
|
74
|
+
tests/test_aliases.py
|
|
75
|
+
tests/test_assessments.py
|
|
76
|
+
tests/test_classification.py
|
|
77
|
+
tests/test_comparisons.py
|
|
78
|
+
tests/test_conversions.py
|
|
79
|
+
tests/test_decorators.py
|
|
80
|
+
tests/test_dynamics.py
|
|
81
|
+
tests/test_fitting.py
|
|
82
|
+
tests/test_generators_instance.py
|
|
83
|
+
tests/test_generators_static.py
|
|
84
|
+
tests/test_hmm.py
|
|
85
|
+
tests/test_measures.py
|
|
86
|
+
tests/test_plotting.py
|
|
87
|
+
tests/test_properties.py
|
|
88
|
+
tests/test_utilities.py
|
|
89
|
+
tests/test_validation.py
|
|
90
|
+
tests/utilities.py
|
|
91
|
+
tests/files/file_empty.txt
|
|
92
|
+
tests/files/file_filled.txt
|
|
93
|
+
tests/files/file_noext
|
|
94
|
+
tests/fixtures/fixtures_aliases.json
|
|
95
|
+
tests/fixtures/fixtures_assessments.json
|
|
96
|
+
tests/fixtures/fixtures_benchmarks.json
|
|
97
|
+
tests/fixtures/fixtures_classification.json
|
|
98
|
+
tests/fixtures/fixtures_comparisons.json
|
|
99
|
+
tests/fixtures/fixtures_conversions.json
|
|
100
|
+
tests/fixtures/fixtures_dynamics.json
|
|
101
|
+
tests/fixtures/fixtures_fitting.json
|
|
102
|
+
tests/fixtures/fixtures_generators_instance.json
|
|
103
|
+
tests/fixtures/fixtures_generators_static.json
|
|
104
|
+
tests/fixtures/fixtures_hmm.json
|
|
105
|
+
tests/fixtures/fixtures_measures.json
|
|
106
|
+
tests/fixtures/fixtures_plotting.json
|
|
107
|
+
tests/fixtures/fixtures_properties.json
|
|
108
|
+
tests/fixtures/fixtures_utilities.json
|
|
109
|
+
tests/fixtures/fixtures_validation.json
|
|
@@ -69,6 +69,13 @@ pip install git+https://github.com/TommasoBelluzzo/PyDTMC.git
|
|
|
69
69
|
|
|
70
70
|
**Note:** [Graphviz](https://graphviz.org/) and [pydot](https://pypi.org/project/pydot/) are recommended for graph visualization using the `plot_graph` function.
|
|
71
71
|
|
|
72
|
+
## Resources
|
|
73
|
+
|
|
74
|
+
For additional functionality, mathematical definitions, and usage examples, refer to the [documentation](https://pydtmc.readthedocs.io/).
|
|
75
|
+
|
|
76
|
+
If you use PyDTMC in your work, please cite the software using its [Zenodo DOI](https://doi.org/10.5281/zenodo.23363778).\
|
|
77
|
+
Citation metadata is also available in the [CITATION.cff](https://github.com/TommasoBelluzzo/PyDTMC/blob/master/CITATION.cff) file.
|
|
78
|
+
|
|
72
79
|
## Quick Start
|
|
73
80
|
|
|
74
81
|
Import the classes from PyDTMC and create instances of a discrete-time Markov chain and a hidden Markov model:
|
|
@@ -184,9 +191,3 @@ plot_trellis(hmm, 10, dpi=300)
|
|
|
184
191
|
```
|
|
185
192
|
|
|
186
193
|

|
|
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.
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
Assessments
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
| An observed sequence may resemble a Markov chain without following its assumptions exactly.
|
|
5
|
+
| Statistical assessments help us examine those assumptions and compare observations with a proposed model.
|
|
6
|
+
| This guide introduces the assessment functions available in PyDTMC using a simple weather process.
|
|
7
|
+
|
|
8
|
+
Model Construction
|
|
9
|
+
------------------
|
|
10
|
+
|
|
11
|
+
| Suppose the weather has two states, ``Dry`` and ``Wet``.
|
|
12
|
+
| The transition matrix describes how the weather changes from one day to the next.
|
|
13
|
+
|
|
14
|
+
.. math::
|
|
15
|
+
|
|
16
|
+
P = \begin{pmatrix}
|
|
17
|
+
0.8 & 0.2 \\
|
|
18
|
+
0.3 & 0.7
|
|
19
|
+
\end{pmatrix}
|
|
20
|
+
|
|
21
|
+
| A dry day is followed by another dry day with probability ``0.8``.
|
|
22
|
+
| A wet day is followed by another wet day with probability ``0.7``.
|
|
23
|
+
|
|
24
|
+
Using PyDTMC, we can create the model and generate a sequence of observations:
|
|
25
|
+
|
|
26
|
+
.. code-block:: python
|
|
27
|
+
|
|
28
|
+
from pydtmc import MarkovChain
|
|
29
|
+
|
|
30
|
+
states = ['Dry', 'Wet']
|
|
31
|
+
mc = MarkovChain([[0.8, 0.2], [0.3, 0.7]], states)
|
|
32
|
+
observations = mc.simulate(1000, initial_state='Dry', seed=42)
|
|
33
|
+
|
|
34
|
+
| The simulation contains the initial state and 1000 subsequent transitions.
|
|
35
|
+
| Using a known model lets us examine the assessments under controlled conditions.
|
|
36
|
+
| Statistical tests may still reject a true hypothesis because of random variation.
|
|
37
|
+
| In a real application, the sequence could instead come from recorded weather observations.
|
|
38
|
+
|
|
39
|
+
Understanding Statistical Assessments
|
|
40
|
+
-------------------------------------
|
|
41
|
+
|
|
42
|
+
| Most assessments begin with a **null hypothesis**, describing a property that the observations are assumed to satisfy.
|
|
43
|
+
| A **test statistic** summarizes how strongly the observations differ from what the null hypothesis predicts.
|
|
44
|
+
| The **p-value** measures how unusual a test statistic at least as extreme as the observed one would be if the null hypothesis were true.
|
|
45
|
+
| We compare the p-value with a chosen **significance level**, usually ``0.05``.
|
|
46
|
+
|
|
47
|
+
| A p-value below ``0.05`` provides evidence against the null hypothesis.
|
|
48
|
+
| A larger p-value means that the assessment has not found sufficient evidence to reject it.
|
|
49
|
+
| It does not prove that the hypothesis is true.
|
|
50
|
+
|
|
51
|
+
| Most PyDTMC assessments return a rejection decision, a p-value, and additional test information.
|
|
52
|
+
| A rejection decision of ``True`` means that the null hypothesis was rejected.
|
|
53
|
+
| Some tests can return ``None`` when a decision cannot be determined from the observations.
|
|
54
|
+
|
|
55
|
+
Independence & Markov Property
|
|
56
|
+
------------------------------
|
|
57
|
+
|
|
58
|
+
| Independence means that knowing today's weather does not help predict tomorrow's weather.
|
|
59
|
+
| The ``assess_independence`` function tests this assumption using observed transitions.
|
|
60
|
+
|
|
61
|
+
.. code-block:: python
|
|
62
|
+
|
|
63
|
+
from pydtmc import assess_independence
|
|
64
|
+
|
|
65
|
+
rejected, p_value, _ = assess_independence(states, observations)
|
|
66
|
+
|
|
67
|
+
print(rejected)
|
|
68
|
+
print(p_value)
|
|
69
|
+
|
|
70
|
+
| Rejecting independence suggests that consecutive weather observations are related.
|
|
71
|
+
| However, dependence alone does not establish the Markov property.
|
|
72
|
+
|
|
73
|
+
| The first-order Markov property means that tomorrow's weather depends on today's weather, not on earlier days once today's weather is known.
|
|
74
|
+
| The ``assess_markov_property`` function checks whether the observed sequence is compatible with this assumption.
|
|
75
|
+
|
|
76
|
+
.. code-block:: python
|
|
77
|
+
|
|
78
|
+
from pydtmc import assess_markov_property
|
|
79
|
+
|
|
80
|
+
rejected, p_value, _ = assess_markov_property(states, observations)
|
|
81
|
+
|
|
82
|
+
print(rejected)
|
|
83
|
+
print(p_value)
|
|
84
|
+
|
|
85
|
+
| Here, a rejection suggests that the immediately preceding state may not contain enough information to describe the next transition.
|
|
86
|
+
| A non-rejection means that the observations do not provide sufficient evidence against a first-order model.
|
|
87
|
+
|
|
88
|
+
Assessing Markov Order
|
|
89
|
+
----------------------
|
|
90
|
+
|
|
91
|
+
| A first-order model uses one previous state to predict the next state.
|
|
92
|
+
| A higher-order model can use several previous states instead.
|
|
93
|
+
| The ``assess_order`` function compares candidate orders and selects one using an information criterion.
|
|
94
|
+
| By default, it uses the **Bayesian Information Criterion (BIC)**, which balances how well a model explains the observations against its complexity.
|
|
95
|
+
|
|
96
|
+
.. code-block:: python
|
|
97
|
+
|
|
98
|
+
from pydtmc import assess_order
|
|
99
|
+
|
|
100
|
+
order, scores = assess_order(states, observations, maximum_order=3)
|
|
101
|
+
|
|
102
|
+
print(order)
|
|
103
|
+
print(scores)
|
|
104
|
+
|
|
105
|
+
| The returned ``order`` is the preferred order among ``0``, ``1``, ``2``, and ``3``.
|
|
106
|
+
| Order ``0`` represents an independent process, while order ``1`` represents an ordinary first-order Markov chain.
|
|
107
|
+
| The ``scores`` dictionary gives the criterion value for each candidate; smaller values are preferred.
|
|
108
|
+
|
|
109
|
+
Time Homogeneity & Change Points
|
|
110
|
+
--------------------------------
|
|
111
|
+
|
|
112
|
+
| A Markov chain is time-homogeneous when its transition probabilities do not change over time.
|
|
113
|
+
| For example, the probability of moving from ``Dry`` to ``Wet`` should follow the same rule throughout the observation period.
|
|
114
|
+
|
|
115
|
+
| The ``assess_time_homogeneity`` function divides the observed transitions into consecutive blocks and compares their behavior.
|
|
116
|
+
|
|
117
|
+
.. code-block:: python
|
|
118
|
+
|
|
119
|
+
from pydtmc import assess_time_homogeneity
|
|
120
|
+
|
|
121
|
+
rejected, p_value, _ = assess_time_homogeneity(states, observations, blocks=2)
|
|
122
|
+
|
|
123
|
+
print(rejected)
|
|
124
|
+
print(p_value)
|
|
125
|
+
|
|
126
|
+
| A rejection suggests that the transition probabilities differ between the two parts of the sequence.
|
|
127
|
+
| A non-rejection does not guarantee that they were perfectly constant.
|
|
128
|
+
|
|
129
|
+
| Instead of comparing predefined time blocks, we may want to locate an abrupt change in transition probabilities.
|
|
130
|
+
| The ``assess_change_point`` function searches for a possible transition between two regimes.
|
|
131
|
+
|
|
132
|
+
.. code-block:: python
|
|
133
|
+
|
|
134
|
+
from pydtmc import assess_change_point
|
|
135
|
+
|
|
136
|
+
change_point, p_value, _ = assess_change_point(states, observations, simulations=200, seed=42)
|
|
137
|
+
|
|
138
|
+
print(change_point)
|
|
139
|
+
print(p_value)
|
|
140
|
+
|
|
141
|
+
| If a statistically significant change is detected, ``change_point`` identifies the first transition of the new regime, using zero-based indexing.
|
|
142
|
+
| Otherwise, the returned change point is ``None``.
|
|
143
|
+
| The p-value is estimated from simulated sequences, so the number of simulations affects its precision.
|
|
144
|
+
|
|
145
|
+
Comparing Observation Sequences
|
|
146
|
+
-------------------------------
|
|
147
|
+
|
|
148
|
+
| We may also collect two separate weather records and ask whether they follow the same transition rules.
|
|
149
|
+
| The ``assess_homogeneity`` function compares the transition probabilities across multiple sequences.
|
|
150
|
+
|
|
151
|
+
.. code-block:: python
|
|
152
|
+
|
|
153
|
+
from pydtmc import assess_homogeneity
|
|
154
|
+
|
|
155
|
+
first = mc.simulate(1000, initial_state='Dry', seed=42)
|
|
156
|
+
second = mc.simulate(1000, initial_state='Wet', seed=43)
|
|
157
|
+
|
|
158
|
+
rejected, p_value, _ = assess_homogeneity(states, [first, second])
|
|
159
|
+
|
|
160
|
+
print(rejected)
|
|
161
|
+
print(p_value)
|
|
162
|
+
|
|
163
|
+
| A rejection suggests that the sequences do not share the same transition probabilities.
|
|
164
|
+
| The test concerns their transition rules, not whether they start in the same state.
|
|
165
|
+
|
|
166
|
+
Theoretical Model Compatibility
|
|
167
|
+
-------------------------------
|
|
168
|
+
|
|
169
|
+
| If a transition matrix is already available, we can ask whether observed transitions agree with it.
|
|
170
|
+
| The ``assess_theoretical_compatibility`` function compares the sequence with the probabilities in the proposed Markov chain.
|
|
171
|
+
|
|
172
|
+
.. code-block:: python
|
|
173
|
+
|
|
174
|
+
from pydtmc import assess_theoretical_compatibility
|
|
175
|
+
|
|
176
|
+
rejected, p_value, _ = assess_theoretical_compatibility(mc, observations)
|
|
177
|
+
|
|
178
|
+
print(rejected)
|
|
179
|
+
print(p_value)
|
|
180
|
+
|
|
181
|
+
| A rejection provides evidence that the observed transitions differ from the proposed model.
|
|
182
|
+
| A non-rejection means that the observed differences are not sufficient to reject it at the chosen significance level.
|
|
183
|
+
|
|
184
|
+
Assessing Stationary Initialization
|
|
185
|
+
-----------------------------------
|
|
186
|
+
|
|
187
|
+
| Time homogeneity means that transition probabilities remain constant over time.
|
|
188
|
+
| Stationarity means that the distribution of the states remains constant over time.
|
|
189
|
+
| A time-homogeneous chain need not start in its stationary distribution.
|
|
190
|
+
| The ``assess_stationarity`` function tests whether independent sequences were initialized according to that distribution.
|
|
191
|
+
|
|
192
|
+
We can generate independent sequences with initial states drawn from the stationary distribution:
|
|
193
|
+
|
|
194
|
+
.. code-block:: python
|
|
195
|
+
|
|
196
|
+
import numpy as np
|
|
197
|
+
from pydtmc import assess_stationarity
|
|
198
|
+
|
|
199
|
+
rng = np.random.default_rng(42)
|
|
200
|
+
starts = rng.choice(states, size=100, p=mc.pi[0])
|
|
201
|
+
|
|
202
|
+
sequences = [
|
|
203
|
+
mc.simulate(10, initial_state=start, seed=i)
|
|
204
|
+
for i, start in enumerate(starts)
|
|
205
|
+
]
|
|
206
|
+
|
|
207
|
+
rejected, p_value, _ = assess_stationarity(mc, sequences)
|
|
208
|
+
|
|
209
|
+
print(rejected)
|
|
210
|
+
print(p_value)
|
|
211
|
+
|
|
212
|
+
| This assessment compares the initial states of the sequences with the model's stationary distribution.
|
|
213
|
+
| It does not test whether one observed sequence has constant transition probabilities.
|
|
214
|
+
| As with the other assessments, a non-rejection does not prove that the starting distribution is stationary.
|