Commit b5e93218 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'log_invgamma' into 'NIFTy_7'

Log invgamma

See merge request !614
parents 1db37c41 a1dd5ebb
Pipeline #97899 passed with stages
in 24 minutes and 57 seconds
......@@ -77,7 +77,8 @@ from .sugar import *
from .plot import Plot
from .library.special_distributions import InverseGammaOperator, UniformOperator, LaplaceOperator
from .library.special_distributions import InverseGammaOperator, \
UniformOperator, LaplaceOperator, LogInverseGammaOperator
from .library.los_response import LOSResponse
from .library.dynamic_operator import (dynamic_operator,
dynamic_lightcone_operator)
......
......@@ -124,6 +124,20 @@ def InverseGammaOperator(domain, alpha, q, delta=1e-2):
return makeOp(q) @ op
def LogInverseGammaOperator(domain, alpha, q, delta=1e-2):
"""Transform a standard normal into the log of an inverse gamma distribution.
See also
--------
:class:`InverseGammaOperator`
"""
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
class UniformOperator(Operator):
"""Transform a standard normal into a uniform distribution.
......
......@@ -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) 2020 Max-Planck-Society
# Copyright(C) 2020-2021 Max-Planck-Society
# Author: Martin Reinecke
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
......@@ -124,7 +124,7 @@ def exponentiate(v, base):
def _exponentiate_helper(v, base):
tmp = np.power(base, v)
return (tmp , np.log(base) * tmp)
return (tmp, np.log(base) * tmp)
ptw_dict = {
......
......@@ -95,6 +95,8 @@ def testInverseGamma(space, seed):
q = 0.73
model = ift.InverseGammaOperator(space, alpha, q)
ift.extra.check_operator(model, pos, ntries=20)
model = ift.LogInverseGammaOperator(space, alpha, q)
ift.extra.check_operator(model, pos, ntries=20)
@pmp("loc", [0, 13.2])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment