How to use the chaospy.distributions.evaluation 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 / operators / tanh.py View on Github external
def _ppf(self, q, dist, cache):
        return numpy.tanh(evaluation.evaluate_inverse(dist, q, cache=cache))
github jonathf / chaospy / chaospy / distributions / copulas / baseclass.py View on Github external
def _cdf(self, x, dist, trans, cache):
        output = evaluation.evaluate_forward(dist, x, cache=cache)
        output = evaluation.evaluate_forward(trans, output, cache=cache)
        return output
github jonathf / chaospy / chaospy / distributions / baseclass.py View on Github external
Returns:
            (numpy.ndarray):
                Evaluated distribution function values, where
                ``out.shape==x_data.shape``.
        """
        x_data = numpy.asfarray(x_data)
        shape = x_data.shape
        x_data = x_data.reshape(len(self), -1)

        q_data = numpy.zeros(x_data.shape)
        indices = (x_data.T > self.upper.T).T
        q_data[indices] = 1
        indices = ~indices & (x_data.T >= self.lower).T

        q_data[indices] = numpy.clip(evaluation.evaluate_forward(
            self, x_data), a_min=0, a_max=1)[indices]

        q_data = q_data.reshape(shape)
        return q_data
github jonathf / chaospy / chaospy / distributions / operators / addition.py View on Github external
def _lower(self, left, right, cache):
        """
        Distribution bounds.

        Example:
            >>> chaospy.Uniform().lower
            array([0.])
            >>> chaospy.Add(chaospy.Uniform(), 2).lower
            array([2.])
            >>> chaospy.Add(2, chaospy.Uniform()).lower
            array([2.])
            >>> chaospy.Add(1, 1).lower
            array([2.])
        """
        left = evaluation.get_forward_cache(left, cache)
        right = evaluation.get_forward_cache(right, cache)
        if isinstance(left, Dist):
            left = evaluation.evaluate_lower(left, cache=cache)
        if isinstance(right, Dist):
            right = evaluation.evaluate_lower(right, cache=cache)
        return left+right
github jonathf / chaospy / chaospy / distributions / operators / negative.py View on Github external
def _lower(self, dist, cache, **kwargs):
        uloc = evaluation.evaluate_upper(dist, cache=cache)
        return self._post_inv(uloc, **kwargs)
github jonathf / chaospy / chaospy / distributions / approximation.py View on Github external
xupper = distribution.upper
    xloc = 0.5*(xlower+xupper)
    xloc = (xloc.T + numpy.zeros(qloc.shape).T).T
    xlower = (xlower.T + numpy.zeros(qloc.shape).T).T
    xupper = (xupper.T + numpy.zeros(qloc.shape).T).T
    uloc = numpy.zeros(qloc.shape)
    ulower = -qloc
    uupper = 1-qloc

    for dim in distribution._precedence_order():
        indices = numpy.ones(qloc.shape[-1], dtype=bool)

        for idx in range(2*iterations):

            # evaluate function:
            uloc[dim, indices] = (evaluation.evaluate_forward(
                distribution, xloc, cache=cache.copy(),
                parameters=parameters)-qloc)[dim, indices]

            # convergence criteria:
            indices[indices] = numpy.any(numpy.abs(uloc) > tol, 0)[indices]
            if not numpy.any(indices):
                break

            # narrow down lower boundary:
            ulower[dim, indices] = numpy.where(uloc < 0, uloc, ulower)[dim, indices]
            xlower[dim, indices] = numpy.where(uloc < 0, xloc, xlower)[dim, indices]

            # narrow down upper boundary:
            uupper[dim, indices] = numpy.where(uloc > 0, uloc, uupper)[dim, indices]
            xupper[dim, indices] = numpy.where(uloc > 0, xloc, xupper)[dim, indices]
github jonathf / chaospy / chaospy / distributions / operators / negative.py View on Github external
def _upper(self, dist, cache, **kwargs):
        uloc = evaluation.evaluate_lower(dist, cache=cache)
        return self._post_inv(uloc, **kwargs)
github jonathf / chaospy / chaospy / distributions / operators / cosh.py View on Github external
def _pdf(self, x, dist, cache):
        """Probability density function."""
        output = evaluation.evaluate_density(dist, numpy.arccosh(x), cache=cache)
        output /= numpy.where(x != 1, numpy.sqrt(x*x-1), numpy.inf)
        return output
github jonathf / chaospy / chaospy / distributions / operators / logarithm10.py View on Github external
def _fwd_cache(self, cache):
        dist = evaluation.get_forward_cache(self.prm["dist"], cache)
        if not isinstance(dist, Dist):
            return numpy.log10(dist)
        return self