# Math#

This submodule contains various mathematical functions. Most of them are imported directly from pytensor.tensor (see there for more details). Doing any kind of math with PyMC random variables, or defining custom likelihoods or priors requires you to use these PyTensor expressions rather than NumPy or Python code.

## Functions exposed in pymc namespace#

 expand_packed_triangular(n, packed[, lower, ...]) Convert a packed triangular matrix into a two dimensional array. invlogit(x[, eps]) The inverse of the logit function, 1 / (1 + exp(-x)). logsumexp(x[, axis, keepdims]) Compute the log of the sum of exponentials of input elements.

## Functions exposed in pymc.math#

 dot(l, r) Return a symbolic dot product. constant(x[, name, ndim, dtype]) Return a TensorConstant with value x. flatten(x[, ndim]) Return a copy of the array collapsed into one dimension. zeros_like(model[, dtype, opt]) equivalent of numpy.zeros_like Parameters ---------- model : tensor dtype : data-type, optional opt : If True, we will return a constant instead of a graph when possible. Useful for PyTensor optimization, not for user building a graph as this have the consequence that model isn't always in the graph. ones_like(model[, dtype, opt]) equivalent of numpy.ones_like Parameters ---------- model : tensor dtype : data-type, optional opt : If True, we will return a constant instead of a graph when possible. Useful for PyTensor optimization, not for user building a graph as this have the consequence that model isn't always in the graph. stack(tensors[, axis]) Stack tensors in sequence on given axis (default is 0). concatenate(tensor_list[, axis]) Alias for join(axis, *tensor_list). sum(input[, axis, dtype, keepdims, acc_dtype]) Computes the sum along the given axis(es) of a tensor input. prod(input[, axis, dtype, keepdims, ...]) Computes the product along the given axis(es) of a tensor input. lt a < b gt a > b le a <= b ge a >= b eq a == b neq a != b switch if cond then ift else iff clip Clip x to be between min and max. where if cond then ift else iff and_ bitwise a & b or_ bitwise a | b exp e^a log base e logarithm of a cos cosine of a sin sine of a tan tangent of a cosh hyperbolic cosine of a sinh hyperbolic sine of a tanh hyperbolic tangent of a sqr square of a sqrt square root of a erf error function erfinv inverse error function dot(l, r) Return a symbolic dot product. maximum elemwise maximum. minimum elemwise minimum. sgn sign of a ceil ceiling of a floor floor of a det Matrix determinant. matrix_inverse Computes the inverse of a matrix $$A$$. extract_diag Return specified diagonals. matrix_dot(*args) Shorthand for product between several dots. Returns the sum of diagonal elements of matrix X. sigmoid Logistic sigmoid function (1 / (1 + exp(-x)), also known as expit or inverse logit logsumexp(x[, axis, keepdims]) Compute the log of the sum of exponentials of input elements. invlogit(x[, eps]) The inverse of the logit function, 1 / (1 + exp(-x)).