efax 2.3.0__tar.gz → 2.4.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.
- efax-2.4.0/LICENSE +201 -0
- {efax-2.3.0 → efax-2.4.0}/PKG-INFO +9 -7
- {efax-2.3.0 → efax-2.4.0}/README.rst +1 -4
- {efax-2.3.0 → efax-2.4.0}/efax/__init__.py +2 -0
- efax-2.4.0/efax/_src/analytic_continuation.py +92 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/chi_square.py +2 -2
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/cmvn/circularly_symmetric.py +20 -7
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/cmvn/unit_variance.py +4 -3
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/complex_normal/complex_normal.py +12 -14
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/complex_normal/unit_variance.py +2 -2
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/complex_von_mises.py +6 -3
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/dirichlet_common.py +2 -2
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/gamma.py +11 -16
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/gen_dirichlet.py +2 -2
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/multivariate_normal/arbitrary.py +8 -7
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/von_mises.py +31 -8
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/wishart.py +3 -4
- {efax-2.3.0 → efax-2.4.0}/efax/_src/expectation_parametrization.py +45 -30
- {efax-2.3.0 → efax-2.4.0}/efax/_src/natural_parametrization.py +4 -38
- {efax-2.3.0 → efax-2.4.0}/efax/_src/parameter/__init__.py +2 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/parameter/support.py +99 -30
- {efax-2.3.0 → efax-2.4.0}/efax/_src/structure/assembler.py +6 -5
- {efax-2.3.0 → efax-2.4.0}/efax/_src/tools.py +2 -1
- {efax-2.3.0 → efax-2.4.0}/pyproject.toml +17 -3
- {efax-2.3.0 → efax-2.4.0}/efax/_src/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/bernoulli.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/beta.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/categorical.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/chi.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/cmvn/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/complex_normal/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/dirichlet.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/exponential.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/geometric.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/inverse_gamma.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/inverse_gaussian.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/log_normal/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/log_normal/log_normal.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/log_normal/unit_variance.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/logarithmic.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/multivariate_normal/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/multivariate_normal/diagonal.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/multivariate_normal/fixed_variance.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/multivariate_normal/isotropic.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/multivariate_normal/unit_variance.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/negative_binomial.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/negative_binomial_common.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/normal/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/normal/normal.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/normal/unit_variance.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/poisson.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/rayleigh.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/softplus_normal/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/softplus_normal/softplus.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/softplus_normal/unit_variance.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/distributions/weibull.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/interfaces/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/interfaces/conjugate_prior.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/interfaces/multidimensional.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/interfaces/samplable.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/iteration.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/mixins/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/mixins/exp_to_nat/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/mixins/exp_to_nat/exp_to_nat.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/mixins/exp_to_nat/optimistix.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/mixins/has_entropy.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/mixins/transformed_parametrization.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/parameter/parameter.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/parameter/ring.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/parametrization.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/structure/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/structure/estimator.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/structure/flattener.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/structure/parameter_names.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/structure/parameter_supports.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/transform/__init__.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/transform/joint.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/_src/types.py +0 -0
- {efax-2.3.0 → efax-2.4.0}/efax/py.typed +0 -0
efax-2.4.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2020, Neil Girdhar
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: efax
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Exponential families for JAX
|
|
5
|
+
Keywords: exponential-family,jax,machine-learning,probability,statistics
|
|
5
6
|
Author: Neil Girdhar
|
|
6
7
|
Author-email: Neil Girdhar <mistersheik@gmail.com>
|
|
7
8
|
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
8
10
|
Classifier: Development Status :: 5 - Production/Stable
|
|
9
11
|
Classifier: Intended Audience :: Science/Research
|
|
10
12
|
Classifier: Operating System :: OS Independent
|
|
@@ -23,12 +25,15 @@ Requires-Dist: numpy>=2.0
|
|
|
23
25
|
Requires-Dist: opt-einsum>=3.4
|
|
24
26
|
Requires-Dist: optimistix>=0.0.9
|
|
25
27
|
Requires-Dist: optype[numpy]>=0.8.0
|
|
26
|
-
Requires-Dist: tjax>=1.
|
|
28
|
+
Requires-Dist: tjax>=1.5.2
|
|
27
29
|
Requires-Dist: typing-extensions>=4.8
|
|
28
30
|
Maintainer: Neil Girdhar
|
|
29
31
|
Maintainer-email: Neil Girdhar <mistersheik@gmail.com>
|
|
30
32
|
Requires-Python: >=3.12, <3.15
|
|
31
|
-
Project-URL:
|
|
33
|
+
Project-URL: Changelog, https://github.com/NeilGirdhar/efax/blob/main/CHANGELOG.md
|
|
34
|
+
Project-URL: Documentation, https://github.com/NeilGirdhar/efax#readme
|
|
35
|
+
Project-URL: Issues, https://github.com/NeilGirdhar/efax/issues
|
|
36
|
+
Project-URL: Source, https://github.com/NeilGirdhar/efax
|
|
32
37
|
Description-Content-Type: text/x-rst
|
|
33
38
|
|
|
34
39
|
.. role:: bash(code)
|
|
@@ -167,10 +172,7 @@ Every `NaturalParametrization` has methods:
|
|
|
167
172
|
- `jeffreys_prior_density`, which returns the square root of the Fisher information
|
|
168
173
|
determinant,
|
|
169
174
|
- `characteristic_function`, which evaluates the characteristic function of the sufficient
|
|
170
|
-
statistics via analytic continuation of the log-normalizer
|
|
171
|
-
as `GammaNP` that keep one or more natural parameters real in `_complexify`, the result
|
|
172
|
-
is approximate — check `NaturalParametrization.characteristic_function_exact` on the
|
|
173
|
-
class before relying on every component), and
|
|
175
|
+
statistics via analytic continuation of the log-normalizer, and
|
|
174
176
|
- `kl_divergence`, which is the KL divergence.
|
|
175
177
|
|
|
176
178
|
Every `ExpectationParametrization` has methods:
|
|
@@ -134,10 +134,7 @@ Every `NaturalParametrization` has methods:
|
|
|
134
134
|
- `jeffreys_prior_density`, which returns the square root of the Fisher information
|
|
135
135
|
determinant,
|
|
136
136
|
- `characteristic_function`, which evaluates the characteristic function of the sufficient
|
|
137
|
-
statistics via analytic continuation of the log-normalizer
|
|
138
|
-
as `GammaNP` that keep one or more natural parameters real in `_complexify`, the result
|
|
139
|
-
is approximate — check `NaturalParametrization.characteristic_function_exact` on the
|
|
140
|
-
class before relying on every component), and
|
|
137
|
+
statistics via analytic continuation of the log-normalizer, and
|
|
141
138
|
- `kl_divergence`, which is the KL divergence.
|
|
142
139
|
|
|
143
140
|
Every `ExpectationParametrization` has methods:
|
|
@@ -84,6 +84,7 @@ from ._src.parameter.parameter import distribution_parameter
|
|
|
84
84
|
from ._src.parameter.ring import BooleanRing, ComplexField, IntegralRing, RealField, Ring
|
|
85
85
|
from ._src.parameter.support import (
|
|
86
86
|
CircularBoundedSupport,
|
|
87
|
+
HermitianMatrixSupport,
|
|
87
88
|
ScalarSupport,
|
|
88
89
|
SimplexSupport,
|
|
89
90
|
SquareMatrixSupport,
|
|
@@ -154,6 +155,7 @@ __all__ = [
|
|
|
154
155
|
"HasEntropyEP",
|
|
155
156
|
"HasEntropyNP",
|
|
156
157
|
"HasGeneralizedConjugatePrior",
|
|
158
|
+
"HermitianMatrixSupport",
|
|
157
159
|
"IntegralRing",
|
|
158
160
|
"InverseGammaEP",
|
|
159
161
|
"InverseGammaNP",
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from array_api_compat import array_namespace
|
|
4
|
+
from tjax import JaxArray, JaxComplexArray, Shape
|
|
5
|
+
from tjax.dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class ComplexContinuation:
|
|
10
|
+
"""Analytic continuation of a complex field's real and imaginary coordinates."""
|
|
11
|
+
|
|
12
|
+
real: JaxComplexArray
|
|
13
|
+
imag: JaxComplexArray
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def shape(self) -> Shape:
|
|
17
|
+
return self.real.shape
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def dtype(self) -> object:
|
|
21
|
+
xp = array_namespace(self.real, self.imag)
|
|
22
|
+
return xp.result_type(self.real, self.imag)
|
|
23
|
+
|
|
24
|
+
def __array_namespace__(self, *, api_version: str | None = None) -> object: # noqa: PLW3201
|
|
25
|
+
return array_namespace(self.real, self.imag, api_version=api_version)
|
|
26
|
+
|
|
27
|
+
def __neg__(self) -> ComplexContinuation:
|
|
28
|
+
return ComplexContinuation(-self.real, -self.imag)
|
|
29
|
+
|
|
30
|
+
def __add__(self, other: JaxArray | ComplexContinuation) -> ComplexContinuation:
|
|
31
|
+
other_real, other_imag = complex_parts(other)
|
|
32
|
+
return ComplexContinuation(self.real + other_real, self.imag + other_imag)
|
|
33
|
+
|
|
34
|
+
def __radd__(self, other: JaxArray | ComplexContinuation) -> ComplexContinuation:
|
|
35
|
+
return self + other
|
|
36
|
+
|
|
37
|
+
def __sub__(self, other: JaxArray | ComplexContinuation) -> ComplexContinuation:
|
|
38
|
+
other_real, other_imag = complex_parts(other)
|
|
39
|
+
return ComplexContinuation(self.real - other_real, self.imag - other_imag)
|
|
40
|
+
|
|
41
|
+
def __rsub__(self, other: JaxArray | ComplexContinuation) -> ComplexContinuation:
|
|
42
|
+
other_real, other_imag = complex_parts(other)
|
|
43
|
+
return ComplexContinuation(other_real - self.real, other_imag - self.imag)
|
|
44
|
+
|
|
45
|
+
def __mul__(self, other: JaxArray | ComplexContinuation) -> ComplexContinuation:
|
|
46
|
+
other_real, other_imag = complex_parts(other)
|
|
47
|
+
return ComplexContinuation(
|
|
48
|
+
self.real * other_real - self.imag * other_imag,
|
|
49
|
+
self.real * other_imag + self.imag * other_real,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
def __rmul__(self, other: JaxArray | ComplexContinuation) -> ComplexContinuation:
|
|
53
|
+
return self * other
|
|
54
|
+
|
|
55
|
+
def __truediv__(self, other: JaxArray | ComplexContinuation) -> ComplexContinuation:
|
|
56
|
+
other_real, other_imag = complex_parts(other)
|
|
57
|
+
denominator = other_real**2 + other_imag**2
|
|
58
|
+
return ComplexContinuation(
|
|
59
|
+
(self.real * other_real + self.imag * other_imag) / denominator,
|
|
60
|
+
(self.imag * other_real - self.real * other_imag) / denominator,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def analytic_continue_parameter(eta: JaxArray, delta: JaxArray) -> JaxArray | ComplexContinuation:
|
|
65
|
+
"""Continue real coordinates without treating complex storage as one coordinate."""
|
|
66
|
+
xp = array_namespace(eta, delta)
|
|
67
|
+
if xp.isdtype(eta.dtype, "complex floating"):
|
|
68
|
+
return ComplexContinuation(
|
|
69
|
+
xp.real(eta) + 1j * xp.real(delta),
|
|
70
|
+
xp.imag(eta) + 1j * xp.imag(delta),
|
|
71
|
+
)
|
|
72
|
+
return eta + 1j * delta
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def complex_parts(z: JaxArray | ComplexContinuation) -> tuple[JaxArray, JaxArray]:
|
|
76
|
+
"""Return the real-coordinate pair represented by a complex value."""
|
|
77
|
+
if isinstance(z, ComplexContinuation):
|
|
78
|
+
return z.real, z.imag
|
|
79
|
+
xp = array_namespace(z)
|
|
80
|
+
return xp.real(z), xp.imag(z)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def analytic_abs_square(z: JaxArray | ComplexContinuation) -> JaxArray:
|
|
84
|
+
"""Return ``real(z)**2 + imag(z)**2`` without conjugating continued coordinates."""
|
|
85
|
+
real, imag = complex_parts(z)
|
|
86
|
+
return real**2 + imag**2
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def complex_value(z: JaxArray | ComplexContinuation) -> JaxArray:
|
|
90
|
+
"""Return the ordinary complex value represented by real and imaginary coordinates."""
|
|
91
|
+
real, imag = complex_parts(z)
|
|
92
|
+
return real + 1j * imag
|
|
@@ -6,7 +6,7 @@ from typing import override
|
|
|
6
6
|
import jax.random as jr
|
|
7
7
|
import jax.scipy.special as jss
|
|
8
8
|
from array_api_compat import array_namespace
|
|
9
|
-
from tjax import JaxArray, JaxRealArray, KeyArray, Shape
|
|
9
|
+
from tjax import JaxArray, JaxRealArray, KeyArray, Shape, complex_gammaln
|
|
10
10
|
from tjax.dataclasses import dataclass
|
|
11
11
|
|
|
12
12
|
from efax._src.interfaces.samplable import Samplable
|
|
@@ -46,7 +46,7 @@ class ChiSquareNP(
|
|
|
46
46
|
@override
|
|
47
47
|
def log_normalizer(self) -> JaxRealArray:
|
|
48
48
|
k_over_two = self.k_over_two_minus_one + 1.0
|
|
49
|
-
return
|
|
49
|
+
return complex_gammaln(k_over_two) - k_over_two * math.log(0.5)
|
|
50
50
|
|
|
51
51
|
@override
|
|
52
52
|
def to_exp(self) -> ChiSquareEP:
|
|
@@ -5,15 +5,24 @@ from typing import override
|
|
|
5
5
|
|
|
6
6
|
import jax.random as jr
|
|
7
7
|
from array_api_compat import array_namespace
|
|
8
|
-
from tjax import
|
|
8
|
+
from tjax import (
|
|
9
|
+
JaxArray,
|
|
10
|
+
JaxComplexArray,
|
|
11
|
+
JaxRealArray,
|
|
12
|
+
KeyArray,
|
|
13
|
+
Shape,
|
|
14
|
+
complex_logdet,
|
|
15
|
+
sesquilinear_outer,
|
|
16
|
+
)
|
|
9
17
|
from tjax.dataclasses import dataclass
|
|
10
18
|
|
|
19
|
+
from efax._src.analytic_continuation import ComplexContinuation, complex_value
|
|
11
20
|
from efax._src.interfaces.multidimensional import Multidimensional
|
|
12
21
|
from efax._src.interfaces.samplable import Samplable
|
|
13
22
|
from efax._src.mixins.has_entropy import HasEntropyEP, HasEntropyNP
|
|
14
23
|
from efax._src.natural_parametrization import NaturalParametrization
|
|
15
24
|
from efax._src.parameter import (
|
|
16
|
-
|
|
25
|
+
HermitianMatrixSupport,
|
|
17
26
|
VectorSupport,
|
|
18
27
|
complex_field,
|
|
19
28
|
distribution_parameter,
|
|
@@ -36,7 +45,7 @@ class ComplexCircularlySymmetricNormalNP(
|
|
|
36
45
|
"""
|
|
37
46
|
|
|
38
47
|
negative_precision: JaxComplexArray = distribution_parameter(
|
|
39
|
-
|
|
48
|
+
HermitianMatrixSupport(negative_semidefinite=True)
|
|
40
49
|
)
|
|
41
50
|
# S = -1/negative_precision, U = 0
|
|
42
51
|
# P = S.conjugate, R = 0
|
|
@@ -57,8 +66,12 @@ class ComplexCircularlySymmetricNormalNP(
|
|
|
57
66
|
|
|
58
67
|
@override
|
|
59
68
|
def log_normalizer(self) -> JaxRealArray:
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
negative_precision = complex_value(self.negative_precision)
|
|
70
|
+
xp = array_namespace(self.negative_precision)
|
|
71
|
+
log_det_s = complex_logdet(-negative_precision)
|
|
72
|
+
# Ordinary parameters must keep the log-normalizer real-valued.
|
|
73
|
+
if not isinstance(self.negative_precision, ComplexContinuation):
|
|
74
|
+
log_det_s = xp.real(log_det_s)
|
|
62
75
|
return -log_det_s + self.dimensions() * math.log(math.pi)
|
|
63
76
|
|
|
64
77
|
@override
|
|
@@ -76,7 +89,7 @@ class ComplexCircularlySymmetricNormalNP(
|
|
|
76
89
|
def sufficient_statistics(
|
|
77
90
|
cls, x: JaxComplexArray, **fixed_parameters: JaxArray
|
|
78
91
|
) -> ComplexCircularlySymmetricNormalEP:
|
|
79
|
-
return ComplexCircularlySymmetricNormalEP(
|
|
92
|
+
return ComplexCircularlySymmetricNormalEP(sesquilinear_outer(x, x))
|
|
80
93
|
|
|
81
94
|
@override
|
|
82
95
|
def sample(self, key: KeyArray, shape: Shape | None = None) -> JaxComplexArray:
|
|
@@ -100,7 +113,7 @@ class ComplexCircularlySymmetricNormalEP(
|
|
|
100
113
|
"""
|
|
101
114
|
|
|
102
115
|
variance: JaxComplexArray = distribution_parameter(
|
|
103
|
-
|
|
116
|
+
HermitianMatrixSupport(positive_semidefinite=True)
|
|
104
117
|
)
|
|
105
118
|
|
|
106
119
|
@property
|
|
@@ -8,6 +8,7 @@ from array_api_compat import array_namespace
|
|
|
8
8
|
from tjax import JaxArray, JaxComplexArray, JaxRealArray, KeyArray, Shape, abs_square
|
|
9
9
|
from tjax.dataclasses import dataclass
|
|
10
10
|
|
|
11
|
+
from efax._src.analytic_continuation import analytic_abs_square
|
|
11
12
|
from efax._src.interfaces.multidimensional import Multidimensional
|
|
12
13
|
from efax._src.interfaces.samplable import Samplable
|
|
13
14
|
from efax._src.mixins.has_entropy import HasEntropyEP, HasEntropyNP
|
|
@@ -50,9 +51,9 @@ class ComplexMultivariateUnitVarianceNormalNP(
|
|
|
50
51
|
|
|
51
52
|
@override
|
|
52
53
|
def log_normalizer(self) -> JaxRealArray:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return xp.sum(
|
|
54
|
+
two_mean_abs_square = analytic_abs_square(self.two_mean)
|
|
55
|
+
xp = array_namespace(two_mean_abs_square)
|
|
56
|
+
return 0.25 * xp.sum(two_mean_abs_square, axis=-1) + self.dimensions() * math.log(math.pi)
|
|
56
57
|
|
|
57
58
|
@override
|
|
58
59
|
def to_exp(self) -> ComplexMultivariateUnitVarianceNormalEP:
|
|
@@ -8,6 +8,7 @@ from array_api_compat import array_namespace
|
|
|
8
8
|
from tjax import JaxArray, JaxComplexArray, JaxRealArray, KeyArray, Shape, abs_square
|
|
9
9
|
from tjax.dataclasses import dataclass
|
|
10
10
|
|
|
11
|
+
from efax._src.analytic_continuation import complex_parts
|
|
11
12
|
from efax._src.interfaces.samplable import Samplable
|
|
12
13
|
from efax._src.mixins.has_entropy import HasEntropyEP, HasEntropyNP
|
|
13
14
|
from efax._src.natural_parametrization import NaturalParametrization
|
|
@@ -62,18 +63,15 @@ class ComplexNormalNP(
|
|
|
62
63
|
|
|
63
64
|
@override
|
|
64
65
|
def log_normalizer(self) -> JaxRealArray:
|
|
65
|
-
xp = array_namespace(self)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
- 0.5 * xp.log(det_h)
|
|
75
|
-
+ math.log(math.pi)
|
|
76
|
-
)
|
|
66
|
+
xp = array_namespace(self.negative_precision)
|
|
67
|
+
eta_x, eta_y = complex_parts(self.mean_times_precision)
|
|
68
|
+
pseudo_x, pseudo_y = complex_parts(self.pseudo_precision)
|
|
69
|
+
h_xx = self.negative_precision + pseudo_x
|
|
70
|
+
h_xy = pseudo_y
|
|
71
|
+
h_yy = self.negative_precision - pseudo_x
|
|
72
|
+
det_h = h_xx * h_yy - h_xy**2
|
|
73
|
+
h_inv_quadratic = (h_yy * eta_x**2 - 2.0 * h_xy * eta_x * eta_y + h_xx * eta_y**2) / det_h
|
|
74
|
+
return math.log(math.pi) - 0.5 * xp.log(det_h) - 0.25 * h_inv_quadratic
|
|
77
75
|
|
|
78
76
|
@override
|
|
79
77
|
def to_exp(self) -> ComplexNormalEP:
|
|
@@ -96,12 +94,12 @@ class ComplexNormalNP(
|
|
|
96
94
|
return ComplexNormalEP(x, abs_square(x), xp.square(x))
|
|
97
95
|
|
|
98
96
|
def _r_s_mu(self) -> tuple[JaxComplexArray, JaxRealArray, JaxComplexArray]:
|
|
99
|
-
xp = array_namespace(self)
|
|
97
|
+
xp = array_namespace(self.negative_precision)
|
|
100
98
|
r = -xp.conj(self.pseudo_precision) / self.negative_precision
|
|
101
99
|
s = xp.reciprocal((abs_square(r) - 1.0) * self.negative_precision)
|
|
102
100
|
k = xp.conj(self.pseudo_precision) / self.negative_precision
|
|
103
101
|
l_eta = (
|
|
104
|
-
0.5
|
|
102
|
+
xp.asarray(0.5)
|
|
105
103
|
* xp.conj(self.mean_times_precision)
|
|
106
104
|
/ ((abs_square(k) - 1.0) * self.negative_precision)
|
|
107
105
|
)
|
|
@@ -8,6 +8,7 @@ from array_api_compat import array_namespace
|
|
|
8
8
|
from tjax import JaxArray, JaxComplexArray, JaxRealArray, KeyArray, Shape, abs_square
|
|
9
9
|
from tjax.dataclasses import dataclass
|
|
10
10
|
|
|
11
|
+
from efax._src.analytic_continuation import analytic_abs_square
|
|
11
12
|
from efax._src.interfaces.samplable import Samplable
|
|
12
13
|
from efax._src.mixins.has_entropy import HasEntropyEP, HasEntropyNP
|
|
13
14
|
from efax._src.natural_parametrization import NaturalParametrization
|
|
@@ -48,8 +49,7 @@ class ComplexUnitVarianceNormalNP(
|
|
|
48
49
|
|
|
49
50
|
@override
|
|
50
51
|
def log_normalizer(self) -> JaxRealArray:
|
|
51
|
-
|
|
52
|
-
return abs_square(mean) + math.log(math.pi)
|
|
52
|
+
return 0.25 * analytic_abs_square(self.two_mean) + math.log(math.pi)
|
|
53
53
|
|
|
54
54
|
@override
|
|
55
55
|
def to_exp(self) -> ComplexUnitVarianceNormalEP:
|
|
@@ -8,12 +8,15 @@ from array_api_compat import array_namespace
|
|
|
8
8
|
from tjax import JaxArray, JaxComplexArray, JaxRealArray, Shape, inverse_softplus, softplus
|
|
9
9
|
from tjax.dataclasses import dataclass
|
|
10
10
|
|
|
11
|
+
from efax._src.analytic_continuation import analytic_abs_square
|
|
11
12
|
from efax._src.mixins.exp_to_nat.exp_to_nat import ExpToNat
|
|
12
13
|
from efax._src.mixins.has_entropy import HasEntropyEP, HasEntropyNP
|
|
13
14
|
from efax._src.natural_parametrization import NaturalParametrization
|
|
14
15
|
from efax._src.parameter import ComplexField, ScalarSupport, complex_field, distribution_parameter
|
|
15
16
|
from efax._src.parametrization import SimpleDistribution
|
|
16
17
|
|
|
18
|
+
from .von_mises import _log_bessel_iv_over_power
|
|
19
|
+
|
|
17
20
|
|
|
18
21
|
@dataclass
|
|
19
22
|
class ComplexVonMisesNP(
|
|
@@ -43,9 +46,9 @@ class ComplexVonMisesNP(
|
|
|
43
46
|
|
|
44
47
|
@override
|
|
45
48
|
def log_normalizer(self) -> JaxRealArray:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
49
|
+
rho = analytic_abs_square(self.mean_times_concentration)
|
|
50
|
+
xp = array_namespace(rho)
|
|
51
|
+
return math.log(2.0 * math.pi) + _log_bessel_iv_over_power(xp.asarray(0.0), rho)
|
|
49
52
|
|
|
50
53
|
@override
|
|
51
54
|
def to_exp(self) -> ComplexVonMisesEP:
|
|
@@ -5,7 +5,7 @@ from typing import Any, override
|
|
|
5
5
|
import jax.random as jr
|
|
6
6
|
import jax.scipy.special as jss
|
|
7
7
|
from array_api_compat import array_namespace
|
|
8
|
-
from tjax import JaxRealArray, KeyArray, Shape
|
|
8
|
+
from tjax import JaxRealArray, KeyArray, Shape, complex_gammaln
|
|
9
9
|
from tjax.dataclasses import dataclass
|
|
10
10
|
|
|
11
11
|
from efax._src.interfaces.multidimensional import Multidimensional
|
|
@@ -33,7 +33,7 @@ class DirichletCommonNP[EP: "DirichletCommonEP[Any]"](
|
|
|
33
33
|
def log_normalizer(self) -> JaxRealArray:
|
|
34
34
|
xp = array_namespace(self)
|
|
35
35
|
q = self.alpha_minus_one
|
|
36
|
-
return xp.sum(
|
|
36
|
+
return xp.sum(complex_gammaln(q + 1.0), axis=-1) - complex_gammaln(
|
|
37
37
|
xp.sum(q, axis=-1) + self.dimensions()
|
|
38
38
|
)
|
|
39
39
|
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import override
|
|
4
4
|
|
|
5
5
|
import jax.random as jr
|
|
6
6
|
import jax.scipy.special as jss
|
|
7
7
|
from array_api_compat import array_namespace
|
|
8
|
-
from tjax import
|
|
8
|
+
from tjax import (
|
|
9
|
+
JaxArray,
|
|
10
|
+
JaxRealArray,
|
|
11
|
+
KeyArray,
|
|
12
|
+
Shape,
|
|
13
|
+
complex_gammaln,
|
|
14
|
+
inverse_softplus,
|
|
15
|
+
softplus,
|
|
16
|
+
)
|
|
9
17
|
from tjax.dataclasses import dataclass
|
|
10
18
|
|
|
11
19
|
from efax._src.interfaces.samplable import Samplable
|
|
@@ -39,8 +47,6 @@ class GammaNP(
|
|
|
39
47
|
shape_minus_one: The shape minus one.
|
|
40
48
|
"""
|
|
41
49
|
|
|
42
|
-
characteristic_function_exact: ClassVar[bool] = False
|
|
43
|
-
|
|
44
50
|
negative_rate: JaxRealArray = distribution_parameter(ScalarSupport(ring=negative_support))
|
|
45
51
|
shape_minus_one: JaxRealArray = distribution_parameter(
|
|
46
52
|
ScalarSupport(ring=RealField(minimum=-1.0))
|
|
@@ -60,7 +66,7 @@ class GammaNP(
|
|
|
60
66
|
def log_normalizer(self) -> JaxRealArray:
|
|
61
67
|
xp = array_namespace(self)
|
|
62
68
|
shape = self.shape_minus_one + 1.0
|
|
63
|
-
return
|
|
69
|
+
return complex_gammaln(shape) - shape * xp.log(-self.negative_rate)
|
|
64
70
|
|
|
65
71
|
@override
|
|
66
72
|
def to_exp(self) -> GammaEP:
|
|
@@ -81,17 +87,6 @@ class GammaNP(
|
|
|
81
87
|
xp = array_namespace(x)
|
|
82
88
|
return GammaEP(x, xp.log(x))
|
|
83
89
|
|
|
84
|
-
@override
|
|
85
|
-
def _complexify(self, t: Self) -> Self: # ty: ignore
|
|
86
|
-
"""Only complexify negative_rate; jss.gammaln does not accept complex inputs.
|
|
87
|
-
|
|
88
|
-
shape_minus_one is kept real, so ``characteristic_function`` cannot
|
|
89
|
-
query the log-x sufficient statistic: that component returns 1 instead
|
|
90
|
-
of the true E[exp(i·t·log x)]. Consequently,
|
|
91
|
-
``characteristic_function_exact = False`` on this class.
|
|
92
|
-
"""
|
|
93
|
-
return type(self)(self.negative_rate + 1j * t.negative_rate, self.shape_minus_one)
|
|
94
|
-
|
|
95
90
|
@override
|
|
96
91
|
def sample(self, key: KeyArray, shape: Shape | None = None) -> JaxRealArray:
|
|
97
92
|
xp = array_namespace(self)
|