How to use the chaospy.distributions.operators.addition.Add function in chaospy

To help you get started, we’ve selected a few chaospy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jonathf / chaospy / chaospy / distributions / collection / power_normal.py View on Github external
def __init__(self, c):
        Dist.__init__(self, c=c)

    def _pdf(self, x, c):
        norm = (2*numpy.pi)**-.5*numpy.exp(-x**2/2.)
        return c*norm*special.ndtr(-x)**(c-1.)

    def _cdf(self, x, c):
        return 1.-special.ndtr(-x)**c

    def _ppf(self, q, c):
        return -special.ndtri(pow(1-q, 1./c))


class PowerNormal(Add):
    """
    Power normal or Box-Cox distribution.

    Args:
        shape (float, Dist):
            Shape parameter
        mu (float, Dist):
            Mean of the normal distribution
        scale (float, Dist):
            Standard deviation of the normal distribution

    Examples:
        >>> distribution = chaospy.PowerNormal(2, 2, 2)
        >>> distribution
        PowerNormal(mu=2, scale=2, shape=2)
        >>> q = numpy.linspace(0,1,6)[1:-1]
github jonathf / chaospy / chaospy / distributions / collection / levy.py View on Github external
def __init__(self, loc=0, scale=1):
        self._repr = {"loc": loc, "scale": scale}
        Add.__init__(self, left=levy()*scale, right=loc)
github jonathf / chaospy / chaospy / distributions / collection / double_gamma.py View on Github external
def __init__(self, shape=1, scale=1, shift=0):
        self._repr = {"shape": shape, "scale": scale, "shift": shift}
        Add.__init__(self, left=double_gamma(shape)*scale, right=shift)
github jonathf / chaospy / chaospy / distributions / collection / generalized_gamma.py View on Github external
def _ppf(self, q, a, c):
        val1 = special.gammaincinv(a, q)
        val2 = special.gammaincinv(a, 1.0-q)
        ic = 1.0/c
        cond = c+0*val1
        return numpy.where(cond > 0, val1**ic, val2**ic)

    def _mom(self, k, a, c):
        return special.gamma((c+k)*1./a)/special.gamma(c*1./a)

    def _lower(self, a, c):
        return 0.


class GeneralizedGamma(Add):
    """
    Generalized gamma distribution

    Args:
        shape1 (float, Dist):
            Shape parameter 1
        shape2 (float, Dist):
            Shape parameter 2
        scale (float, Dist):
            Scaling parameter
        shift (float, Dist):
            Location parameter

    Examples:
        >>> distribution = chaospy.GeneralizedGamma(3, 2, 2, 2)
        >>> distribution
github jonathf / chaospy / chaospy / distributions / collection / pareto1.py View on Github external
def __init__(self, shape=1, scale=1, loc=0):
        self._repr = {"shape": shape, "scale": scale, "loc": loc}
        Add.__init__(self, left=pareto1(shape)*scale, right=loc)
github jonathf / chaospy / chaospy / distributions / collection / folded_normal.py View on Github external
Dist.__init__(self, c=c)

    def _pdf(self, x, c):
        return numpy.sqrt(2.0/numpy.pi)*numpy.cosh(c*x)*numpy.exp(-(x*x+c*c)/2.0)

    def _cdf(self, x, c):
        return special.ndtr(x-c) + special.ndtr(x+c) - 1.0

    def _lower(self, c):
        return 0.

    def _upper(self, c):
        return 7.5+c


class FoldedNormal(Add):
    """
    Folded normal distribution.

    Args:
        mu (float, Dist):
            Location parameter in normal distribution
        sigma (float, Dist):
            Scaling parameter (in both normal and fold)
        loc (float, Dist):
            Location of fold

    Examples:
        >>> distribution = chaospy.FoldedNormal(3, 2, 1)
        >>> distribution
        FoldedNormal(loc=1, mu=3, sigma=2)
        >>> q = numpy.linspace(0, 1, 6)[1:-1]
github jonathf / chaospy / chaospy / distributions / collection / weibull.py View on Github external
def __init__(self, shape=1, scale=1, shift=0):
        self._repr = {"shape": shape, "scale": scale, "shift": shift}
        Add.__init__(self, left=weibull(shape)*scale, right=shift)
github jonathf / chaospy / chaospy / distributions / collection / log_gamma.py View on Github external
"""Log-gamma distribution."""

    def __init__(self, c):
        Dist.__init__(self, c=c)

    def _pdf(self, x, c):
        return numpy.exp(c*x-numpy.exp(x)-special.gammaln(c))

    def _cdf(self, x, c):
        return special.gammainc(c, numpy.exp(x))

    def _ppf(self, q, c):
        return numpy.log(special.gammaincinv(c,q))


class LogGamma(Add):
    """
    Log-gamma distribution

    Args:
        shape (float, Dist):
            Shape parameter
        scale (float, Dist):
            Scaling parameter
        shift (float, Dist):
            Location parameter

    Examples:
        >>> distribution = chaospy.LogGamma(2, 2, 1)
        >>> distribution
        LogGamma(scale=2, shape=2, shift=1)
        >>> q = numpy.linspace(0,1,6)[1:-1]
github jonathf / chaospy / chaospy / distributions / collection / log_gamma.py View on Github external
def __init__(self, shape=1, scale=1, shift=0):
        self._repr = {"shape": shape, "scale": scale, "shift": shift}
        Add.__init__(self, left=log_gamma(shape)*scale, right=shift)
github jonathf / chaospy / chaospy / distributions / collection / gompertz.py View on Github external
def __init__(self, shape, scale, shift):
        self._repr = {"shape": shape, "scale": scale, "shift": shift}
        Add.__init__(self, left=gompertz(shape)*scale, right=shift)