log_semiring ====================== .. py:module:: jaxns.internals.log_semiring .. rubric:: :code:`jaxns.internals.log_semiring` .. rubric:: Module Contents .. py:function:: logaddexp(x1, x2) Equivalent to logaddexp but supporting complex arguments. see np.logaddexp .. py:function:: signed_logaddexp(log_abs_val1, sign1, log_abs_val2, sign2) Equivalent of logaddexp but for signed quantities too. Broadcasting supported. :param log_abs_val1: Logarithm of absolute value of val1, :math:`\log(|x_1|)` :param sign1: Sign of val1, :math:`\mathrm{sign}(x_1)` :param log_abs_val2: Logarithm of absolute value of val2, :math:`\log(|x_2|)` :param sign2: Sign of val2, :math:`\mathrm{sign}(x_2)` :returns: (:math:`\log(|x_1+x_2|)`, :math:`\mathrm{sign}(x_1+x_2)`) .. py:function:: cumulative_logsumexp(u, sign=None, reverse=False, axis=0) .. py:class:: LogSpace(log_abs_val, sign = None) Bases: :py:obj:`object` .. py:method:: from_signed_value(value) :staticmethod: .. py:property:: dtype .. py:property:: log_abs_val .. py:property:: sign .. py:property:: value .. py:method:: __neg__() .. py:method:: __add__(other) Implements addition in log space log(exp(log_A) + exp(log_B)) :param other: ndarray or LogSpace, if ndarray assumed to be log(B) :returns: LogSpace .. py:method:: __sub__(other) Implements addition in log space log(exp(log_A) - exp(log_B)) :param other: ndarray or LogSpace, if ndarray assumed to be log(B) :returns: LogSpace .. py:method:: __mul__(other) Implements addition in log space log(exp(log_A) * exp(log_B)) :param other: ndarray or LogSpace, if ndarray assumed to be log(B) :returns: LogSpace .. py:method:: __repr__() .. py:method:: sum(axis=-1, keepdims=False) .. py:method:: nansum(axis=-1, keepdims=False) .. py:method:: cumsum(axis=0, reverse=False) .. py:method:: cumprod(axis=0) .. py:method:: mean(axis=-1, keepdims=False) .. py:method:: var(axis=-1, keepdims=False) .. py:method:: log() .. py:method:: exp() .. py:method:: sqrt() .. py:method:: abs() .. py:method:: diff() .. py:method:: square() .. py:method:: argmax() .. py:method:: maximum(other) .. py:method:: minimum(other) .. py:method:: max() .. py:method:: min() .. py:method:: concatenate(other, axis=0) .. py:method:: __getitem__(item) .. py:property:: signed_log .. py:method:: __gt__(other) .. py:method:: __lt__(other) .. py:method:: __ge__(other) .. py:method:: __le__(other) .. py:property:: size .. py:method:: __pow__(n) Implements power in log space log(exp(log_A)**n) :param n: int or float :returns: LogSpace .. py:method:: __truediv__(other) Implements addition in log space log(exp(log_A) / exp(log_B)) :param other: ndarray or LogSpace, if ndarray assumed to be log(B) :returns: LogSpace .. py:function:: is_complex(a) .. py:function:: normalise_log_space(x, norm_type = 'sum') Safely normalise a LogSpace, accounting for zero-sum. :param x: LogSpace to normalise :param norm_type: 'sum' or 'max' normalisation :returns: normalised LogSpace