Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
5beafe79
Commit
5beafe79
authored
Apr 01, 2021
by
Philipp Arras
Browse files
LogInverseGammaOperator: treat scaling correctly
parent
413e8ee5
Pipeline
#97452
passed with stages
in 11 minutes and 56 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/library/special_distributions.py
View file @
5beafe79
...
...
@@ -23,6 +23,7 @@ from .. import random
from
..domain_tuple
import
DomainTuple
from
..domains.unstructured_domain
import
UnstructuredDomain
from
..field
import
Field
from
..operators.adder
import
Adder
from
..operators.operator
import
Operator
from
..sugar
import
makeOp
...
...
@@ -133,9 +134,8 @@ def LogInverseGammaOperator(domain, alpha, q, delta=1e-2):
"""
op
=
_InterpolationOperator
(
domain
,
lambda
x
:
np
.
log
(
invgamma
.
ppf
(
norm
.
_cdf
(
x
),
float
(
alpha
))),
-
8.2
,
8.2
,
delta
)
if
np
.
isscalar
(
q
):
return
op
.
scale
(
q
)
return
makeOp
(
q
)
@
op
q
=
np
.
log
(
q
)
if
np
.
isscalar
(
q
)
else
q
.
log
()
return
Adder
(
q
,
domain
=
op
.
target
)
@
op
class
UniformOperator
(
Operator
):
...
...
test/test_operators/test_interpolated.py
View file @
5beafe79
...
...
@@ -11,7 +11,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-201
9
Max-Planck-Society
# Copyright(C) 2013-20
2
1 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
...
...
@@ -41,6 +41,9 @@ def testInterpolationAccuracy(space, seed):
if
not
np
.
isscalar
(
q
):
qfld
=
ift
.
makeField
(
space
,
q
)
op
=
ift
.
InverseGammaOperator
(
space
,
alpha
,
qfld
)
op1
=
ift
.
LogInverseGammaOperator
(
space
,
alpha
,
qfld
).
exp
()
arr1
=
op
(
pos
).
val
arr2
=
op1
(
pos
).
val
arr0
=
invgamma
.
ppf
(
norm
.
cdf
(
pos
.
val
),
alpha
,
scale
=
q
)
assert_allclose
(
arr0
,
arr1
)
assert_allclose
(
arr0
,
arr2
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment