CUQIpy 1.4.1__tar.gz → 1.4.1.post0.dev136__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.
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/CUQIpy.egg-info/PKG-INFO +2 -2
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/CUQIpy.egg-info/SOURCES.txt +32 -26
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/CUQIpy.egg-info/requires.txt +1 -1
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/PKG-INFO +2 -2
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/__init__.py +2 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/_version.py +3 -3
- cuqipy-1.4.1.post0.dev136/cuqi/algebra/__init__.py +2 -0
- cuqipy-1.4.1/cuqi/experimental/algebra/_randomvariable.py → cuqipy-1.4.1.post0.dev136/cuqi/algebra/_random_variable.py +4 -4
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/config.py +7 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/density/_density.py +9 -1
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/__init__.py +1 -1
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_distribution.py +1 -1
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_joint_distribution.py +99 -14
- cuqipy-1.4.1.post0.dev136/cuqi/experimental/__init__.py +2 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/experimental/_recommender.py +4 -4
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/geometry/__init__.py +2 -0
- cuqipy-1.4.1/cuqi/experimental/geometry/_productgeometry.py → cuqipy-1.4.1.post0.dev136/cuqi/geometry/_product_geometry.py +1 -1
- cuqipy-1.4.1.post0.dev136/cuqi/implicitprior/__init__.py +5 -0
- cuqipy-1.4.1.post0.dev136/cuqi/legacy/__init__.py +2 -0
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_cwmh.py +2 -2
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_gibbs.py +9 -5
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_hmc.py +2 -2
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_langevin_algorithm.py +5 -5
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_laplace_approximation.py +1 -1
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_mh.py +2 -2
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_pcn.py +3 -3
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_rto.py +2 -2
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_sampler.py +5 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/model/_model.py +16 -16
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/pde/__init__.py +4 -0
- cuqipy-1.4.1.post0.dev136/cuqi/pde/_observation_map.py +36 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/pde/_pde.py +53 -22
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/problem/_problem.py +87 -80
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/__init__.py +14 -13
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_conjugate.py +1 -1
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_conjugate_approx.py +2 -2
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_cwmh.py +2 -2
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_direct.py +1 -1
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_gibbs.py +37 -18
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_hmc.py +2 -2
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_langevin_algorithm.py +5 -5
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_laplace_approximation.py +1 -1
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_mh.py +1 -1
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_pcn.py +11 -4
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_rto.py +1 -1
- {cuqipy-1.4.1/cuqi/experimental/mcmc → cuqipy-1.4.1.post0.dev136/cuqi/sampler}/_sampler.py +40 -28
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/requirements.txt +1 -1
- cuqipy-1.4.1.post0.dev136/tests/test_algebra.py +68 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_bayesian_inversion.py +8 -8
- cuqipy-1.4.1.post0.dev136/tests/test_config.py +13 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_implicit_priors.py +6 -6
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_joint_distribution.py +173 -1
- cuqipy-1.4.1/tests/test_sampler.py → cuqipy-1.4.1.post0.dev136/tests/test_legacy_sampler.py +27 -27
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_model.py +3 -3
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_pde.py +7 -5
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_problem.py +0 -1
- cuqipy-1.4.1.post0.dev136/tests/test_product_geometry.py +165 -0
- cuqipy-1.4.1.post0.dev136/tests/test_random_variable.py +372 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_samples.py +6 -6
- cuqipy-1.4.1.post0.dev136/tests/test_z_mcmc.py +1835 -0
- cuqipy-1.4.1/cuqi/experimental/__init__.py +0 -5
- cuqipy-1.4.1/cuqi/experimental/algebra/__init__.py +0 -2
- cuqipy-1.4.1/cuqi/experimental/geometry/__init__.py +0 -1
- cuqipy-1.4.1/cuqi/implicitprior/__init__.py +0 -5
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/CUQIpy.egg-info/dependency_links.txt +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/CUQIpy.egg-info/top_level.txt +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/LICENSE +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/README.md +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/_messages.py +0 -0
- /cuqipy-1.4.1/cuqi/experimental/algebra/_ast.py → /cuqipy-1.4.1.post0.dev136/cuqi/algebra/_abstract_syntax_tree.py +0 -0
- /cuqipy-1.4.1/cuqi/experimental/algebra/_orderedset.py → /cuqipy-1.4.1.post0.dev136/cuqi/algebra/_ordered_set.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/array/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/array/_array.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/data/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/data/_data.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/data/astronaut.npz +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/data/camera.npz +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/data/cat.npz +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/data/cookie.png +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/data/satellite.mat +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/density/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/diagnostics.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_beta.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_cauchy.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_cmrf.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_custom.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_gamma.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_gaussian.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_gmrf.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_inverse_gamma.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_laplace.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_lmrf.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_lognormal.py +0 -0
- /cuqipy-1.4.1/cuqi/distribution/_modifiedhalfnormal.py → /cuqipy-1.4.1.post0.dev136/cuqi/distribution/_modified_half_normal.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_normal.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_posterior.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_smoothed_laplace.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_truncated_normal.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/distribution/_uniform.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/geometry/_geometry.py +0 -0
- /cuqipy-1.4.1/cuqi/implicitprior/_regularizedGaussian.py → /cuqipy-1.4.1.post0.dev136/cuqi/implicitprior/_regularized_gaussian.py +0 -0
- /cuqipy-1.4.1/cuqi/implicitprior/_regularizedGMRF.py → /cuqipy-1.4.1.post0.dev136/cuqi/implicitprior/_regularized_gmrf.py +0 -0
- /cuqipy-1.4.1/cuqi/implicitprior/_regularizedUnboundedUniform.py → /cuqipy-1.4.1.post0.dev136/cuqi/implicitprior/_regularized_unbounded_uniform.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/implicitprior/_restorator.py +0 -0
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/__init__.py +0 -0
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_conjugate.py +0 -0
- {cuqipy-1.4.1/cuqi → cuqipy-1.4.1.post0.dev136/cuqi/legacy}/sampler/_conjugate_approx.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/likelihood/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/likelihood/_likelihood.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/model/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/operator/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/operator/_operator.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/problem/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/samples/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/samples/_samples.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/solver/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/solver/_solver.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/testproblem/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/testproblem/_testproblem.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/utilities/__init__.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/utilities/_get_python_variable_name.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/cuqi/utilities/_utilities.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/pyproject.toml +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/setup.cfg +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/setup.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_abstract_distribution_density.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_density.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_distribution.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_distributions_shape.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_geometry.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_likelihood.py +0 -0
- /cuqipy-1.4.1/tests/test_MRFs.py → /cuqipy-1.4.1.post0.dev136/tests/test_mrfs.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_posterior.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_solver.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_testproblem.py +0 -0
- {cuqipy-1.4.1 → cuqipy-1.4.1.post0.dev136}/tests/test_utilities.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: CUQIpy
|
|
3
|
-
Version: 1.4.1
|
|
3
|
+
Version: 1.4.1.post0.dev136
|
|
4
4
|
Summary: Computational Uncertainty Quantification for Inverse problems in Python
|
|
5
5
|
Maintainer-email: "Nicolai A. B. Riis" <nabr@dtu.dk>, "Jakob S. Jørgensen" <jakj@dtu.dk>, "Amal M. Alghamdi" <amaal@dtu.dk>, Chao Zhang <chaz@dtu.dk>
|
|
6
6
|
License: Apache License
|
|
@@ -201,7 +201,7 @@ Requires-Python: >=3.9
|
|
|
201
201
|
Description-Content-Type: text/markdown
|
|
202
202
|
License-File: LICENSE
|
|
203
203
|
Requires-Dist: matplotlib
|
|
204
|
-
Requires-Dist: numpy
|
|
204
|
+
Requires-Dist: numpy<=2.2.0
|
|
205
205
|
Requires-Dist: scipy==1.12.0; python_version <= "3.9"
|
|
206
206
|
Requires-Dist: scipy; python_version > "3.9"
|
|
207
207
|
Requires-Dist: arviz
|
|
@@ -13,6 +13,10 @@ cuqi/_messages.py
|
|
|
13
13
|
cuqi/_version.py
|
|
14
14
|
cuqi/config.py
|
|
15
15
|
cuqi/diagnostics.py
|
|
16
|
+
cuqi/algebra/__init__.py
|
|
17
|
+
cuqi/algebra/_abstract_syntax_tree.py
|
|
18
|
+
cuqi/algebra/_ordered_set.py
|
|
19
|
+
cuqi/algebra/_random_variable.py
|
|
16
20
|
cuqi/array/__init__.py
|
|
17
21
|
cuqi/array/_array.py
|
|
18
22
|
cuqi/data/__init__.py
|
|
@@ -38,7 +42,7 @@ cuqi/distribution/_joint_distribution.py
|
|
|
38
42
|
cuqi/distribution/_laplace.py
|
|
39
43
|
cuqi/distribution/_lmrf.py
|
|
40
44
|
cuqi/distribution/_lognormal.py
|
|
41
|
-
cuqi/distribution/
|
|
45
|
+
cuqi/distribution/_modified_half_normal.py
|
|
42
46
|
cuqi/distribution/_normal.py
|
|
43
47
|
cuqi/distribution/_posterior.py
|
|
44
48
|
cuqi/distribution/_smoothed_laplace.py
|
|
@@ -46,32 +50,27 @@ cuqi/distribution/_truncated_normal.py
|
|
|
46
50
|
cuqi/distribution/_uniform.py
|
|
47
51
|
cuqi/experimental/__init__.py
|
|
48
52
|
cuqi/experimental/_recommender.py
|
|
49
|
-
cuqi/experimental/algebra/__init__.py
|
|
50
|
-
cuqi/experimental/algebra/_ast.py
|
|
51
|
-
cuqi/experimental/algebra/_orderedset.py
|
|
52
|
-
cuqi/experimental/algebra/_randomvariable.py
|
|
53
|
-
cuqi/experimental/geometry/__init__.py
|
|
54
|
-
cuqi/experimental/geometry/_productgeometry.py
|
|
55
|
-
cuqi/experimental/mcmc/__init__.py
|
|
56
|
-
cuqi/experimental/mcmc/_conjugate.py
|
|
57
|
-
cuqi/experimental/mcmc/_conjugate_approx.py
|
|
58
|
-
cuqi/experimental/mcmc/_cwmh.py
|
|
59
|
-
cuqi/experimental/mcmc/_direct.py
|
|
60
|
-
cuqi/experimental/mcmc/_gibbs.py
|
|
61
|
-
cuqi/experimental/mcmc/_hmc.py
|
|
62
|
-
cuqi/experimental/mcmc/_langevin_algorithm.py
|
|
63
|
-
cuqi/experimental/mcmc/_laplace_approximation.py
|
|
64
|
-
cuqi/experimental/mcmc/_mh.py
|
|
65
|
-
cuqi/experimental/mcmc/_pcn.py
|
|
66
|
-
cuqi/experimental/mcmc/_rto.py
|
|
67
|
-
cuqi/experimental/mcmc/_sampler.py
|
|
68
53
|
cuqi/geometry/__init__.py
|
|
69
54
|
cuqi/geometry/_geometry.py
|
|
55
|
+
cuqi/geometry/_product_geometry.py
|
|
70
56
|
cuqi/implicitprior/__init__.py
|
|
71
|
-
cuqi/implicitprior/
|
|
72
|
-
cuqi/implicitprior/
|
|
73
|
-
cuqi/implicitprior/
|
|
57
|
+
cuqi/implicitprior/_regularized_gaussian.py
|
|
58
|
+
cuqi/implicitprior/_regularized_gmrf.py
|
|
59
|
+
cuqi/implicitprior/_regularized_unbounded_uniform.py
|
|
74
60
|
cuqi/implicitprior/_restorator.py
|
|
61
|
+
cuqi/legacy/__init__.py
|
|
62
|
+
cuqi/legacy/sampler/__init__.py
|
|
63
|
+
cuqi/legacy/sampler/_conjugate.py
|
|
64
|
+
cuqi/legacy/sampler/_conjugate_approx.py
|
|
65
|
+
cuqi/legacy/sampler/_cwmh.py
|
|
66
|
+
cuqi/legacy/sampler/_gibbs.py
|
|
67
|
+
cuqi/legacy/sampler/_hmc.py
|
|
68
|
+
cuqi/legacy/sampler/_langevin_algorithm.py
|
|
69
|
+
cuqi/legacy/sampler/_laplace_approximation.py
|
|
70
|
+
cuqi/legacy/sampler/_mh.py
|
|
71
|
+
cuqi/legacy/sampler/_pcn.py
|
|
72
|
+
cuqi/legacy/sampler/_rto.py
|
|
73
|
+
cuqi/legacy/sampler/_sampler.py
|
|
75
74
|
cuqi/likelihood/__init__.py
|
|
76
75
|
cuqi/likelihood/_likelihood.py
|
|
77
76
|
cuqi/model/__init__.py
|
|
@@ -79,6 +78,7 @@ cuqi/model/_model.py
|
|
|
79
78
|
cuqi/operator/__init__.py
|
|
80
79
|
cuqi/operator/_operator.py
|
|
81
80
|
cuqi/pde/__init__.py
|
|
81
|
+
cuqi/pde/_observation_map.py
|
|
82
82
|
cuqi/pde/_pde.py
|
|
83
83
|
cuqi/problem/__init__.py
|
|
84
84
|
cuqi/problem/_problem.py
|
|
@@ -86,6 +86,7 @@ cuqi/sampler/__init__.py
|
|
|
86
86
|
cuqi/sampler/_conjugate.py
|
|
87
87
|
cuqi/sampler/_conjugate_approx.py
|
|
88
88
|
cuqi/sampler/_cwmh.py
|
|
89
|
+
cuqi/sampler/_direct.py
|
|
89
90
|
cuqi/sampler/_gibbs.py
|
|
90
91
|
cuqi/sampler/_hmc.py
|
|
91
92
|
cuqi/sampler/_langevin_algorithm.py
|
|
@@ -103,22 +104,27 @@ cuqi/testproblem/_testproblem.py
|
|
|
103
104
|
cuqi/utilities/__init__.py
|
|
104
105
|
cuqi/utilities/_get_python_variable_name.py
|
|
105
106
|
cuqi/utilities/_utilities.py
|
|
106
|
-
tests/test_MRFs.py
|
|
107
107
|
tests/test_abstract_distribution_density.py
|
|
108
|
+
tests/test_algebra.py
|
|
108
109
|
tests/test_bayesian_inversion.py
|
|
110
|
+
tests/test_config.py
|
|
109
111
|
tests/test_density.py
|
|
110
112
|
tests/test_distribution.py
|
|
111
113
|
tests/test_distributions_shape.py
|
|
112
114
|
tests/test_geometry.py
|
|
113
115
|
tests/test_implicit_priors.py
|
|
114
116
|
tests/test_joint_distribution.py
|
|
117
|
+
tests/test_legacy_sampler.py
|
|
115
118
|
tests/test_likelihood.py
|
|
116
119
|
tests/test_model.py
|
|
120
|
+
tests/test_mrfs.py
|
|
117
121
|
tests/test_pde.py
|
|
118
122
|
tests/test_posterior.py
|
|
119
123
|
tests/test_problem.py
|
|
120
|
-
tests/
|
|
124
|
+
tests/test_product_geometry.py
|
|
125
|
+
tests/test_random_variable.py
|
|
121
126
|
tests/test_samples.py
|
|
122
127
|
tests/test_solver.py
|
|
123
128
|
tests/test_testproblem.py
|
|
124
|
-
tests/test_utilities.py
|
|
129
|
+
tests/test_utilities.py
|
|
130
|
+
tests/test_z_mcmc.py
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: CUQIpy
|
|
3
|
-
Version: 1.4.1
|
|
3
|
+
Version: 1.4.1.post0.dev136
|
|
4
4
|
Summary: Computational Uncertainty Quantification for Inverse problems in Python
|
|
5
5
|
Maintainer-email: "Nicolai A. B. Riis" <nabr@dtu.dk>, "Jakob S. Jørgensen" <jakj@dtu.dk>, "Amal M. Alghamdi" <amaal@dtu.dk>, Chao Zhang <chaz@dtu.dk>
|
|
6
6
|
License: Apache License
|
|
@@ -201,7 +201,7 @@ Requires-Python: >=3.9
|
|
|
201
201
|
Description-Content-Type: text/markdown
|
|
202
202
|
License-File: LICENSE
|
|
203
203
|
Requires-Dist: matplotlib
|
|
204
|
-
Requires-Dist: numpy
|
|
204
|
+
Requires-Dist: numpy<=2.2.0
|
|
205
205
|
Requires-Dist: scipy==1.12.0; python_version <= "3.9"
|
|
206
206
|
Requires-Dist: scipy; python_version > "3.9"
|
|
207
207
|
Requires-Dist: arviz
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from . import data
|
|
2
2
|
from . import density
|
|
3
3
|
from . import diagnostics
|
|
4
|
+
from . import algebra
|
|
4
5
|
from . import distribution
|
|
5
6
|
from . import experimental
|
|
6
7
|
from . import geometry
|
|
@@ -11,6 +12,7 @@ from . import operator
|
|
|
11
12
|
from . import pde
|
|
12
13
|
from . import problem
|
|
13
14
|
from . import sampler
|
|
15
|
+
from . import legacy
|
|
14
16
|
from . import array
|
|
15
17
|
from . import samples
|
|
16
18
|
from . import solver
|
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "
|
|
11
|
+
"date": "2026-01-08T10:38:50+0100",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "1.4.1"
|
|
14
|
+
"full-revisionid": "5831beecd0dc3785bd3ed04c243b2ea1d63bfdc9",
|
|
15
|
+
"version": "1.4.1.post0.dev136"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from typing import List, Any, Union
|
|
3
|
-
from .
|
|
4
|
-
from .
|
|
3
|
+
from ._abstract_syntax_tree import VariableNode, Node
|
|
4
|
+
from ._ordered_set import _OrderedSet
|
|
5
5
|
import operator
|
|
6
6
|
import cuqi
|
|
7
7
|
from cuqi.distribution import Distribution
|
|
@@ -58,7 +58,7 @@ class RandomVariable:
|
|
|
58
58
|
|
|
59
59
|
from cuqi.testproblem import Deconvolution1D
|
|
60
60
|
from cuqi.distribution import Gaussian, Gamma, GMRF
|
|
61
|
-
from cuqi.
|
|
61
|
+
from cuqi.algebra import RandomVariable
|
|
62
62
|
from cuqi.problem import BayesianProblem
|
|
63
63
|
|
|
64
64
|
import numpy as np
|
|
@@ -79,7 +79,7 @@ class RandomVariable:
|
|
|
79
79
|
.. code-block:: python
|
|
80
80
|
|
|
81
81
|
from cuqi.distribution import Gaussian, Gamma
|
|
82
|
-
from cuqi.
|
|
82
|
+
from cuqi.algebra import RandomVariable, VariableNode
|
|
83
83
|
|
|
84
84
|
# Define the variables
|
|
85
85
|
x = VariableNode('x')
|
|
@@ -12,3 +12,10 @@ MAX_STACK_SEARCH_DEPTH = 1000
|
|
|
12
12
|
|
|
13
13
|
MIN_DIM_SPARSE = 75
|
|
14
14
|
""" Minimum dimension to start storing Nd-arrays as sparse for N>2. The minimum dimension is defined as MIN_DIM_SPARSE^N. """
|
|
15
|
+
|
|
16
|
+
PROGRESS_BAR_DYNAMIC_UPDATE = True
|
|
17
|
+
""" If True, progress bars are updated frequently (dynamic updates).
|
|
18
|
+
If False, progress bars are minimal/static (only shown at start and end),
|
|
19
|
+
which is useful, for example, when building documentation or the Jupyter book
|
|
20
|
+
(CUQI-Book).
|
|
21
|
+
"""
|
|
@@ -143,7 +143,15 @@ class Density(ABC):
|
|
|
143
143
|
def enable_FD(self, epsilon=1e-8):
|
|
144
144
|
""" Enable finite difference approximation for logd gradient. Note
|
|
145
145
|
that if enabled, the FD approximation will be used even if the
|
|
146
|
-
_gradient method is implemented.
|
|
146
|
+
_gradient method is implemented.
|
|
147
|
+
|
|
148
|
+
Parameters
|
|
149
|
+
----------
|
|
150
|
+
epsilon : float
|
|
151
|
+
|
|
152
|
+
Spacing (step size) to use for finite difference approximation for logd
|
|
153
|
+
gradient for each variable. Default is 1e-8.
|
|
154
|
+
"""
|
|
147
155
|
self._FD_enabled = True
|
|
148
156
|
self._FD_epsilon = epsilon
|
|
149
157
|
|
|
@@ -3,7 +3,7 @@ from ._beta import Beta
|
|
|
3
3
|
from ._cauchy import Cauchy
|
|
4
4
|
from ._cmrf import CMRF
|
|
5
5
|
from ._gamma import Gamma
|
|
6
|
-
from .
|
|
6
|
+
from ._modified_half_normal import ModifiedHalfNormal
|
|
7
7
|
from ._gaussian import Gaussian, JointGaussianSqrtPrec
|
|
8
8
|
from ._gmrf import GMRF
|
|
9
9
|
from ._inverse_gamma import InverseGamma
|
|
@@ -419,5 +419,5 @@ class Distribution(Density, ABC):
|
|
|
419
419
|
@property
|
|
420
420
|
def rv(self):
|
|
421
421
|
""" Return a random variable object representing the distribution. """
|
|
422
|
-
from cuqi.
|
|
422
|
+
from cuqi.algebra import RandomVariable
|
|
423
423
|
return RandomVariable(self)
|
|
@@ -62,16 +62,16 @@ class JointDistribution:
|
|
|
62
62
|
posterior = joint(y=y_obs)
|
|
63
63
|
|
|
64
64
|
"""
|
|
65
|
-
def __init__(self, *densities: [Density, cuqi.
|
|
65
|
+
def __init__(self, *densities: [Density, cuqi.algebra.RandomVariable]):
|
|
66
66
|
""" Create a joint distribution from the given densities. """
|
|
67
67
|
|
|
68
68
|
# Check if all RandomVariables are simple (not-transformed)
|
|
69
69
|
for density in densities:
|
|
70
|
-
if isinstance(density, cuqi.
|
|
70
|
+
if isinstance(density, cuqi.algebra.RandomVariable) and density.is_transformed:
|
|
71
71
|
raise ValueError(f"To be used in {self.__class__.__name__}, all RandomVariables must be untransformed.")
|
|
72
72
|
|
|
73
73
|
# Convert potential random variables to their underlying distribution
|
|
74
|
-
densities = [density.distribution if isinstance(density, cuqi.
|
|
74
|
+
densities = [density.distribution if isinstance(density, cuqi.algebra.RandomVariable) else density for density in densities]
|
|
75
75
|
|
|
76
76
|
# Ensure all densities have unique names
|
|
77
77
|
names = [density.name for density in densities]
|
|
@@ -84,6 +84,8 @@ class JointDistribution:
|
|
|
84
84
|
cond_vars = self._get_conditioning_variables()
|
|
85
85
|
if len(cond_vars) > 0:
|
|
86
86
|
raise ValueError(f"Every density parameter must have a distribution (prior). Missing prior for {cond_vars}.")
|
|
87
|
+
# Initialize finite difference gradient approximation settings
|
|
88
|
+
self.disable_FD()
|
|
87
89
|
|
|
88
90
|
# --------- Public properties ---------
|
|
89
91
|
@property
|
|
@@ -96,6 +98,38 @@ class JointDistribution:
|
|
|
96
98
|
""" Returns the geometries of the joint distribution. """
|
|
97
99
|
return [dist.geometry for dist in self._distributions]
|
|
98
100
|
|
|
101
|
+
@property
|
|
102
|
+
def FD_enabled(self):
|
|
103
|
+
""" Returns a dictionary of keys and booleans indicating for each
|
|
104
|
+
parameter name (key) if finite difference approximation of the logd
|
|
105
|
+
gradient is enabled. """
|
|
106
|
+
par_names = self.get_parameter_names()
|
|
107
|
+
FD_enabled = {
|
|
108
|
+
par_name: self.FD_epsilon[par_name] is not None for par_name in par_names
|
|
109
|
+
}
|
|
110
|
+
return FD_enabled
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def FD_epsilon(self):
|
|
114
|
+
""" Returns a dictionary indicating for each parameter name the
|
|
115
|
+
spacing for the finite difference approximation of the logd gradient."""
|
|
116
|
+
return self._FD_epsilon
|
|
117
|
+
|
|
118
|
+
@FD_epsilon.setter
|
|
119
|
+
def FD_epsilon(self, value):
|
|
120
|
+
""" Set the spacing for the finite difference approximation of the
|
|
121
|
+
logd gradient as a dictionary. The keys are the parameter names.
|
|
122
|
+
The value for each key is either None (no FD approximation) or a float
|
|
123
|
+
representing the FD step size.
|
|
124
|
+
"""
|
|
125
|
+
par_names = self.get_parameter_names()
|
|
126
|
+
if value is None:
|
|
127
|
+
self._FD_epsilon = {par_name: None for par_name in par_names}
|
|
128
|
+
else:
|
|
129
|
+
if set(value.keys()) != set(par_names):
|
|
130
|
+
raise ValueError("Keys of FD_epsilon must match the parameter names of the distribution "+f" {par_names}")
|
|
131
|
+
self._FD_epsilon = value
|
|
132
|
+
|
|
99
133
|
# --------- Public methods ---------
|
|
100
134
|
def logd(self, *args, **kwargs):
|
|
101
135
|
""" Evaluate the un-normalized log density function. """
|
|
@@ -136,6 +170,33 @@ class JointDistribution:
|
|
|
136
170
|
# Can reduce to Posterior, Likelihood or Distribution.
|
|
137
171
|
return new_joint._reduce_to_single_density()
|
|
138
172
|
|
|
173
|
+
def enable_FD(self, epsilon=None):
|
|
174
|
+
""" Enable finite difference approximation for logd gradient. Note
|
|
175
|
+
that if enabled, the FD approximation will be used even if the
|
|
176
|
+
_gradient method is implemented. By default, all parameters
|
|
177
|
+
will have FD enabled with a step size of 1e-8.
|
|
178
|
+
|
|
179
|
+
Parameters
|
|
180
|
+
----------
|
|
181
|
+
epsilon : dict, *optional*
|
|
182
|
+
|
|
183
|
+
Dictionary indicating the spacing (step size) to use for finite
|
|
184
|
+
difference approximation for logd gradient for each variable.
|
|
185
|
+
|
|
186
|
+
Keys are variable names.
|
|
187
|
+
Values are either a float to enable FD with the given value as the FD
|
|
188
|
+
step size, or None to disable FD for that variable. Default is 1e-8 for
|
|
189
|
+
all variables.
|
|
190
|
+
"""
|
|
191
|
+
if epsilon is None:
|
|
192
|
+
epsilon = {par_name: 1e-8 for par_name in self.get_parameter_names()}
|
|
193
|
+
self.FD_epsilon = epsilon
|
|
194
|
+
|
|
195
|
+
def disable_FD(self):
|
|
196
|
+
""" Disable finite difference approximation for logd gradient. """
|
|
197
|
+
par_names = self.get_parameter_names()
|
|
198
|
+
self.FD_epsilon = {par_name: None for par_name in par_names}
|
|
199
|
+
|
|
139
200
|
def get_parameter_names(self) -> List[str]:
|
|
140
201
|
""" Returns the parameter names of the joint distribution. """
|
|
141
202
|
return [dist.name for dist in self._distributions]
|
|
@@ -202,34 +263,58 @@ class JointDistribution:
|
|
|
202
263
|
# Count number of distributions and likelihoods
|
|
203
264
|
n_dist = len(self._distributions)
|
|
204
265
|
n_likelihood = len(self._likelihoods)
|
|
266
|
+
reduced_FD_epsilon = {par_name:self.FD_epsilon[par_name] for par_name in self.get_parameter_names()}
|
|
267
|
+
self.enable_FD(epsilon=reduced_FD_epsilon)
|
|
205
268
|
|
|
206
269
|
# Cant reduce if there are multiple distributions or likelihoods
|
|
207
270
|
if n_dist > 1:
|
|
208
271
|
return self
|
|
209
272
|
|
|
273
|
+
# If only evaluated densities left return joint to ensure logd method is available
|
|
274
|
+
if n_dist == 0 and n_likelihood == 0:
|
|
275
|
+
return self
|
|
276
|
+
|
|
277
|
+
# Extract the parameter name of the distribution
|
|
278
|
+
if n_dist == 1:
|
|
279
|
+
par_name = self._distributions[0].name
|
|
280
|
+
elif n_likelihood == 1:
|
|
281
|
+
par_name = self._likelihoods[0].name
|
|
282
|
+
else:
|
|
283
|
+
par_name = None
|
|
284
|
+
|
|
210
285
|
# If exactly one distribution and multiple likelihoods reduce
|
|
211
286
|
if n_dist == 1 and n_likelihood > 1:
|
|
212
|
-
|
|
213
|
-
|
|
287
|
+
reduced_distribution = MultipleLikelihoodPosterior(*self._densities)
|
|
288
|
+
reduced_FD_epsilon = {par_name:self.FD_epsilon[par_name]}
|
|
289
|
+
|
|
214
290
|
# If exactly one distribution and one likelihood its a Posterior
|
|
215
291
|
if n_dist == 1 and n_likelihood == 1:
|
|
216
292
|
# Ensure parameter names match, otherwise return the joint distribution
|
|
217
293
|
if set(self._likelihoods[0].get_parameter_names()) != set(self._distributions[0].get_parameter_names()):
|
|
218
294
|
return self
|
|
219
|
-
|
|
295
|
+
reduced_distribution = Posterior(self._likelihoods[0], self._distributions[0])
|
|
296
|
+
reduced_distribution = self._add_constants_to_density(reduced_distribution)
|
|
297
|
+
reduced_FD_epsilon = self.FD_epsilon[par_name]
|
|
220
298
|
|
|
221
299
|
# If exactly one distribution and no likelihoods its a Distribution
|
|
222
300
|
if n_dist == 1 and n_likelihood == 0:
|
|
223
|
-
|
|
224
|
-
|
|
301
|
+
# Intentionally skip enabling FD here. If the user wants FD, they
|
|
302
|
+
# can enable it for this particular distribution before forming
|
|
303
|
+
# the joint distribution.
|
|
304
|
+
return self._add_constants_to_density(self._distributions[0])
|
|
305
|
+
|
|
225
306
|
# If no distributions and exactly one likelihood its a Likelihood
|
|
226
307
|
if n_likelihood == 1 and n_dist == 0:
|
|
227
|
-
|
|
308
|
+
# This case seems to not happen in practice, but we include it for
|
|
309
|
+
# completeness.
|
|
310
|
+
reduced_distribution = self._likelihoods[0]
|
|
311
|
+
reduced_FD_epsilon = self.FD_epsilon[par_name]
|
|
312
|
+
|
|
313
|
+
if self.FD_enabled[par_name]:
|
|
314
|
+
reduced_distribution.enable_FD(epsilon=reduced_FD_epsilon)
|
|
315
|
+
|
|
316
|
+
return reduced_distribution
|
|
228
317
|
|
|
229
|
-
# If only evaluated densities left return joint to ensure logd method is available
|
|
230
|
-
if n_dist == 0 and n_likelihood == 0:
|
|
231
|
-
return self
|
|
232
|
-
|
|
233
318
|
def _add_constants_to_density(self, density: Density):
|
|
234
319
|
""" Add the constants (evaluated densities) to a single density. Used when reducing to single density. """
|
|
235
320
|
|
|
@@ -274,7 +359,7 @@ class JointDistribution:
|
|
|
274
359
|
if len(cond_vars) > 0:
|
|
275
360
|
msg += f"|{cond_vars}"
|
|
276
361
|
msg += ")"
|
|
277
|
-
|
|
362
|
+
|
|
278
363
|
msg += "\n"
|
|
279
364
|
msg += " Densities: \n"
|
|
280
365
|
|
|
@@ -3,7 +3,7 @@ import inspect
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
|
|
5
5
|
# This import makes suggest_sampler easier to read
|
|
6
|
-
import cuqi.
|
|
6
|
+
import cuqi.sampler as samplers
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class SamplerRecommender(object):
|
|
@@ -15,7 +15,7 @@ class SamplerRecommender(object):
|
|
|
15
15
|
target: Density or JointDistribution
|
|
16
16
|
Distribution to get sampler recommendations for.
|
|
17
17
|
|
|
18
|
-
exceptions: list[cuqi.
|
|
18
|
+
exceptions: list[cuqi.sampler.Sampler], *optional*
|
|
19
19
|
Samplers not to be recommended.
|
|
20
20
|
|
|
21
21
|
Example
|
|
@@ -104,7 +104,7 @@ class SamplerRecommender(object):
|
|
|
104
104
|
|
|
105
105
|
"""
|
|
106
106
|
|
|
107
|
-
all_samplers = [(name, cls) for name, cls in inspect.getmembers(cuqi.
|
|
107
|
+
all_samplers = [(name, cls) for name, cls in inspect.getmembers(cuqi.sampler, inspect.isclass) if issubclass(cls, cuqi.sampler.Sampler)]
|
|
108
108
|
valid_samplers = []
|
|
109
109
|
|
|
110
110
|
for name, sampler in all_samplers:
|
|
@@ -116,7 +116,7 @@ class SamplerRecommender(object):
|
|
|
116
116
|
|
|
117
117
|
# Need a separate case for HybridGibbs
|
|
118
118
|
if self.valid_HybridGibbs_sampling_strategy() is not None:
|
|
119
|
-
valid_samplers += [cuqi.
|
|
119
|
+
valid_samplers += [cuqi.sampler.HybridGibbs.__name__ if as_string else cuqi.sampler.HybridGibbs]
|
|
120
120
|
|
|
121
121
|
return valid_samplers
|
|
122
122
|
|
|
@@ -16,6 +16,8 @@ from ._geometry import (
|
|
|
16
16
|
StepExpansion
|
|
17
17
|
)
|
|
18
18
|
|
|
19
|
+
from ._product_geometry import _ProductGeometry
|
|
20
|
+
|
|
19
21
|
|
|
20
22
|
# TODO: We will remove the use of identity geometries in the future
|
|
21
23
|
_identity_geometries = [_DefaultGeometry1D, _DefaultGeometry2D, Continuous1D, Continuous2D, Discrete, Image2D]
|
|
@@ -17,7 +17,7 @@ class _ProductGeometry(Geometry):
|
|
|
17
17
|
.. code-block:: python
|
|
18
18
|
import numpy as np
|
|
19
19
|
from cuqi.geometry import Continuous1D, Discrete
|
|
20
|
-
from cuqi.
|
|
20
|
+
from cuqi.geometry import _ProductGeometry
|
|
21
21
|
geometry1 = Continuous1D(np.linspace(0, 1, 100))
|
|
22
22
|
geometry2 = Discrete(["sound_speed"])
|
|
23
23
|
product_geometry = _ProductGeometry(geometry1, geometry2)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
from ._regularized_gaussian import RegularizedGaussian, ConstrainedGaussian, NonnegativeGaussian
|
|
2
|
+
from ._regularized_gmrf import RegularizedGMRF, ConstrainedGMRF, NonnegativeGMRF
|
|
3
|
+
from ._regularized_unbounded_uniform import RegularizedUnboundedUniform
|
|
4
|
+
from ._restorator import RestorationPrior, MoreauYoshidaPrior, TweediePrior
|
|
5
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
import cuqi
|
|
3
|
-
from cuqi.sampler import ProposalBasedSampler
|
|
3
|
+
from cuqi.legacy.sampler import ProposalBasedSampler
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class CWMH(ProposalBasedSampler):
|
|
@@ -48,7 +48,7 @@ class CWMH(ProposalBasedSampler):
|
|
|
48
48
|
target = cuqi.distribution.UserDefinedDistribution(dim=dim, logpdf_func=logpdf_func)
|
|
49
49
|
|
|
50
50
|
# Set up sampler
|
|
51
|
-
sampler = cuqi.sampler.CWMH(target, scale=1)
|
|
51
|
+
sampler = cuqi.legacy.sampler.CWMH(target, scale=1)
|
|
52
52
|
|
|
53
53
|
# Sample
|
|
54
54
|
samples = sampler.sample(2000)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from cuqi.distribution import JointDistribution
|
|
2
|
-
from cuqi.sampler import Sampler
|
|
2
|
+
from cuqi.legacy.sampler import Sampler
|
|
3
3
|
from cuqi.samples import Samples
|
|
4
4
|
from typing import Dict, Union
|
|
5
5
|
import numpy as np
|
|
6
6
|
import sys
|
|
7
|
-
|
|
7
|
+
import warnings
|
|
8
8
|
|
|
9
9
|
class Gibbs:
|
|
10
10
|
"""
|
|
@@ -52,12 +52,12 @@ class Gibbs:
|
|
|
52
52
|
|
|
53
53
|
# Define sampling strategy
|
|
54
54
|
sampling_strategy = {
|
|
55
|
-
'x': cuqi.sampler.LinearRTO,
|
|
56
|
-
('d', 'l'): cuqi.sampler.Conjugate,
|
|
55
|
+
'x': cuqi.legacy.sampler.LinearRTO,
|
|
56
|
+
('d', 'l'): cuqi.legacy.sampler.Conjugate,
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
# Define Gibbs sampler
|
|
60
|
-
sampler = cuqi.sampler.Gibbs(posterior, sampling_strategy)
|
|
60
|
+
sampler = cuqi.legacy.sampler.Gibbs(posterior, sampling_strategy)
|
|
61
61
|
|
|
62
62
|
# Run sampler
|
|
63
63
|
samples = sampler.sample(Ns=1000, Nb=200)
|
|
@@ -71,6 +71,10 @@ class Gibbs:
|
|
|
71
71
|
|
|
72
72
|
def __init__(self, target: JointDistribution, sampling_strategy: Dict[Union[str,tuple], Sampler]):
|
|
73
73
|
|
|
74
|
+
warnings.warn(f"\nYou are using the legacy sampler '{self.__class__.__name__}'.\n"
|
|
75
|
+
f"This will be removed in a future release of CUQIpy.\n"
|
|
76
|
+
f"Please consider using the new samplers in the 'cuqi.sampler' module.\n", UserWarning, stacklevel=2)
|
|
77
|
+
|
|
74
78
|
# Store target and allow conditioning to reduce to a single density
|
|
75
79
|
self.target = target() # Create a copy of target distribution (to avoid modifying the original)
|
|
76
80
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
-
from cuqi.sampler import Sampler
|
|
2
|
+
from cuqi.legacy.sampler import Sampler
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
# another implementation is in https://github.com/mfouesneau/NUTS
|
|
@@ -50,7 +50,7 @@ class NUTS(Sampler):
|
|
|
50
50
|
target = tp.posterior
|
|
51
51
|
|
|
52
52
|
# Set up sampler
|
|
53
|
-
sampler = cuqi.sampler.NUTS(target)
|
|
53
|
+
sampler = cuqi.legacy.sampler.NUTS(target)
|
|
54
54
|
|
|
55
55
|
# Sample
|
|
56
56
|
samples = sampler.sample(10000, 5000)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
import cuqi
|
|
3
|
-
from cuqi.sampler import Sampler
|
|
3
|
+
from cuqi.legacy.sampler import Sampler
|
|
4
4
|
|
|
5
5
|
class ULA(Sampler):
|
|
6
6
|
"""Unadjusted Langevin algorithm (ULA) (Roberts and Tweedie, 1996)
|
|
@@ -55,12 +55,12 @@ class ULA(Sampler):
|
|
|
55
55
|
gradient_func=gradient_func)
|
|
56
56
|
|
|
57
57
|
# Set up sampler
|
|
58
|
-
sampler = cuqi.sampler.ULA(target, scale=1/dim**2)
|
|
58
|
+
sampler = cuqi.legacy.sampler.ULA(target, scale=1/dim**2)
|
|
59
59
|
|
|
60
60
|
# Sample
|
|
61
61
|
samples = sampler.sample(2000)
|
|
62
62
|
|
|
63
|
-
A Deblur example can be found in demos/
|
|
63
|
+
A Deblur example can be found in demos/demo27_ula.py
|
|
64
64
|
"""
|
|
65
65
|
def __init__(self, target, scale, x0=None, dim=None, rng=None, **kwargs):
|
|
66
66
|
super().__init__(target, x0=x0, dim=dim, **kwargs)
|
|
@@ -162,12 +162,12 @@ class MALA(ULA):
|
|
|
162
162
|
gradient_func=gradient_func)
|
|
163
163
|
|
|
164
164
|
# Set up sampler
|
|
165
|
-
sampler = cuqi.sampler.MALA(target, scale=1/5**2)
|
|
165
|
+
sampler = cuqi.legacy.sampler.MALA(target, scale=1/5**2)
|
|
166
166
|
|
|
167
167
|
# Sample
|
|
168
168
|
samples = sampler.sample(2000)
|
|
169
169
|
|
|
170
|
-
A Deblur example can be found in demos/
|
|
170
|
+
A Deblur example can be found in demos/demo28_mala.py
|
|
171
171
|
"""
|
|
172
172
|
def __init__(self, target, scale, x0=None, dim=None, rng=None, **kwargs):
|
|
173
173
|
super().__init__(target, scale, x0=x0, dim=dim, rng=rng, **kwargs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
import cuqi
|
|
3
|
-
from cuqi.sampler import ProposalBasedSampler
|
|
3
|
+
from cuqi.legacy.sampler import ProposalBasedSampler
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class MH(ProposalBasedSampler):
|
|
@@ -48,7 +48,7 @@ class MH(ProposalBasedSampler):
|
|
|
48
48
|
target = cuqi.distribution.UserDefinedDistribution(dim=dim, logpdf_func=logpdf_func)
|
|
49
49
|
|
|
50
50
|
# Set up sampler
|
|
51
|
-
sampler = cuqi.sampler.MH(target, scale=1)
|
|
51
|
+
sampler = cuqi.legacy.sampler.MH(target, scale=1)
|
|
52
52
|
|
|
53
53
|
# Sample
|
|
54
54
|
samples = sampler.sample(2000)
|