-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
We already have support for
- add (and subtraction via addition)
- mul (and division and neg via multiplication)
- pow (inludes reciprocal, sqrt, sqr, etc...)
- exp
- log
- abs
Other operations we could support
- cosh, sinh and tanh (maybe other?)
- erf, erfc, erfcx?
- arcsinh, arctanh (see https://discourse.pymc.io/t/the-sinh-arcsinh-normal-distribution/12136)
- arccosh is multivalued, or complex? Didn't have time to dig
pymc/pymc/logprob/transforms.py
Line 339 in f3ce16f
valid_scalar_types = (Exp, Log, Add, Mul, Pow, Abs) |
Other operations we can support via rewrites to already supported forms
- exp2, log2, log10
- log1p
- expm1
- log1mexp
- log1pexp (softplus)
- sigmoid
Example of such rewrites:
pymc/pymc/logprob/transforms.py
Lines 467 to 483 in f3ce16f
@node_rewriter([neg]) | |
def measurable_neg_to_product(fgraph, node): | |
"""Convert negation of `MeasurableVariable`s to product with `-1`.""" | |
inp = node.inputs[0] | |
if not (inp.owner and isinstance(inp.owner.op, MeasurableVariable)): | |
return None | |
rv_map_feature: Optional[PreserveRVMappings] = getattr(fgraph, "preserve_rv_mappings", None) | |
if rv_map_feature is None: | |
return None # pragma: no cover | |
# Only apply this rewrite if the variable is unvalued | |
if inp in rv_map_feature.rv_values: | |
return None # pragma: no cover | |
return [pt.mul(inp, -1.0)] |
duncanhobbs and twieckilarryshamalama