How to use the chaospy.distributions.evaluation.evaluate_forward 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 / power.py View on Github external
else:
            assert numpy.all(left > 0), "imaginary result"

            y = (numpy.log(numpy.abs(xloc) + 1.*(xloc <= 0)) /
                 numpy.log(numpy.abs(left)+1.*(left == 1)))

            out = evaluation.evaluate_forward(right, y, cache=cache.copy())
            out = numpy.where(xloc <= 0, 0., out)
            return out

        y = numpy.sign(xloc)*numpy.abs(xloc)**(1./right)
        pairs = numpy.sign(xloc**right) != -1

        out1, out2 = (
            evaluation.evaluate_forward(left, y, cache=cache),
            evaluation.evaluate_forward(left, -y, cache=cache),
        )
        out = numpy.where(right < 0, 1-out1, out1-pairs*out2)
        return out
github jonathf / chaospy / chaospy / distributions / operators / sinh.py View on Github external
def _cdf(self, x, dist, cache):
        return evaluation.evaluate_forward(dist, numpy.arcsinh(x), cache=cache)
github jonathf / chaospy / chaospy / distributions / operators / tan.py View on Github external
def _cdf(self, x, dist, cache):
        return evaluation.evaluate_forward(dist, numpy.arctan(x))
github jonathf / chaospy / chaospy / distributions / operators / logarithm10.py View on Github external
def _cdf(self, xloc, dist, cache):
        """Cumulative distribution function."""
        return evaluation.evaluate_forward(dist, 10**xloc, cache=cache)
github jonathf / chaospy / chaospy / distributions / approximation.py View on Github external
>>> approximate_density(distribution, xloc).round(4)
        array([[0.0242, 0.0399, 0.0242]])
        >>> distribution.pdf(xloc).round(4)
        array([[0.0242, 0.0399, 0.0242]])
    """
    if parameters is None:
        parameters = dist.prm.copy()
    if cache is None:
        cache = {}

    xloc = numpy.asfarray(xloc)
    lo, up = numpy.min(xloc), numpy.max(xloc)
    mu = .5*(lo+up)
    eps = numpy.where(xloc < mu, eps, -eps)*xloc

    floc = evaluation.evaluate_forward(
        dist, xloc, parameters=parameters.copy(), cache=cache.copy())
    for d in range(len(dist)):
        xloc[d] += eps[d]
        tmp = evaluation.evaluate_forward(
            dist, xloc, parameters=parameters.copy(), cache=cache.copy())
        floc[d] -= tmp[d]
        xloc[d] -= eps[d]

    floc = numpy.abs(floc / eps)
    return floc
github jonathf / chaospy / chaospy / distributions / approximation.py View on Github external
"""
    if parameters is None:
        parameters = dist.prm.copy()
    if cache is None:
        cache = {}

    xloc = numpy.asfarray(xloc)
    lo, up = numpy.min(xloc), numpy.max(xloc)
    mu = .5*(lo+up)
    eps = numpy.where(xloc < mu, eps, -eps)*xloc

    floc = evaluation.evaluate_forward(
        dist, xloc, parameters=parameters.copy(), cache=cache.copy())
    for d in range(len(dist)):
        xloc[d] += eps[d]
        tmp = evaluation.evaluate_forward(
            dist, xloc, parameters=parameters.copy(), cache=cache.copy())
        floc[d] -= tmp[d]
        xloc[d] -= eps[d]

    floc = numpy.abs(floc / eps)
    return floc
github jonathf / chaospy / chaospy / distributions / operators / arcsin.py View on Github external
def _cdf(self, x, dist, cache):
        return evaluation.evaluate_forward(dist, numpy.sin(x), cache=cache)
github jonathf / chaospy / chaospy / distributions / operators / trunkation.py View on Github external
if isinstance(left, Dist):
            if isinstance(right, Dist):
                raise StochasticallyDependentError(
                    "under-defined distribution {} or {}".format(left, right))

            right = (numpy.array(right).T*numpy.ones(q.shape).T).T
            uloc = evaluation.evaluate_forward(left, right, cache=cache.copy())
            out = evaluation.evaluate_inverse(left, q*uloc, cache=cache)

        elif not isinstance(right, Dist):
            raise StochasticallyDependentError(
                "truncated variable indirectly depends on underlying variable")
        else:
            left = (numpy.array(left).T*numpy.ones(q.shape).T).T
            uloc = evaluation.evaluate_forward(right, left)
            out = evaluation.evaluate_inverse(right, q*(1-uloc)+uloc, cache=cache)
        return out
github jonathf / chaospy / chaospy / distributions / operators / cosh.py View on Github external
def _cdf(self, x, dist, cache):
        return evaluation.evaluate_forward(dist, numpy.arccosh(x), cache=cache)