Commit a1dd5ebb authored by Philipp Arras's avatar Philipp Arras
Browse files

Add LogInverseGammaOperator

parent e5afb727
Pipeline #97345 passed with stages
in 12 minutes and 25 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.
......
......@@ -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