def _bnd(self, xloc, left, right, cache):
        """
        Distribution bounds.

        Example:
            >>> print(chaospy.Uniform().range([-2, 0, 2, 4]))
            [[0. 0. 0. 0.]
             [1. 1. 1. 1.]]
            >>> print(chaospy.Pow(chaospy.Uniform(), 2).range([-2, 0, 2, 4]))
            [[0. 0. 0. 0.]
             [1. 1. 1. 1.]]
            >>> print(chaospy.Pow(chaospy.Uniform(1, 2), -1).range([-2, 0, 2, 4]))
            [[0.5 0.5 0.5 0.5]
             [1.  1.  1.  1. ]]
            >>> print(chaospy.Pow(2, chaospy.Uniform()).range([-2, 0, 2, 4]))
            [[1. 1. 1. 1.]
             [2. 2. 2. 2.]]
            >>> print(chaospy.Pow(2, chaospy.Uniform(-1, 0)).range([-2, 0, 2, 4]))
            [[0.5 0.5 0.5 0.5]
             [1.  1.  1.  1. ]]
            >>> print(chaospy.Pow(2, 3).range([-2, 0, 2, 4]))
            [[8. 8. 8. 8.]
             [8. 8. 8. 8.]]
        """
        left = evaluation.get_forward_cache(left, cache)
        right = evaluation.get_forward_cache(right, cache)

        if isinstance(left, Dist):
            if isinstance(right, Dist):
                raise StochasticallyDependentError(
                    "under-defined distribution {} or {}".format(left, right))
        elif not isinstance(right, Dist):
            return left**right, left**right
        else:
            output = numpy.ones(xloc.shape)
            left = left * output
            assert numpy.all(left >= 0), "root of negative number"

            indices = xloc > 0
            output[indices] = numpy.log(xloc[indices])
            output[~indices] = -numpy.inf

            indices = left != 1
            output[indices] /= numpy.log(left[indices])

            output = evaluation.evaluate_bound(right, output, cache=cache)
            output = left**output
            output[:] = (
                numpy.where(output[0] < output[1], output[0], output[1]),
                numpy.where(output[0] < output[1], output[1], output[0]),
            )
            return output

        output = numpy.zeros(xloc.shape)
        right = right + output

        indices = right > 0
        output[indices] = numpy.abs(xloc[indices])**(1/right[indices])
        output[indices] *= numpy.sign(xloc[indices])
        output[right == 0] = 1
        output[(xloc == 0) & (right < 0)] = numpy.inf

        output = evaluation.evaluate_bound(left, output, cache=cache)

        pair = right % 2 == 0
        bnd_ = numpy.empty(output.shape)
        bnd_[0] = numpy.where(pair*(output[0]*output[1] < 0), 0, output[0])
        bnd_[0] = numpy.where(pair*(output[0]*output[1] > 0), \
                numpy.min(numpy.abs(output), 0), bnd_[0])**right
        bnd_[1] = numpy.where(pair, numpy.max(numpy.abs(output), 0),
                output[1])**right

        bnd_[0], bnd_[1] = (
            numpy.where(bnd_[0] < bnd_[1], bnd_[0], bnd_[1]),
            numpy.where(bnd_[0] < bnd_[1], bnd_[1], bnd_[0]),
        )
        return bnd_
def _bnd ( self , xloc , left , right , cache ) : left = evaluation . get_forward_cache ( left , cache ) right = evaluation . get_forward_cache ( right , cache ) if isinstance ( left , Dist ) : if isinstance ( right , Dist ) : raise StochasticallyDependentError ( "under-defined distribution {} or {}" . format ( left , right ) ) elif not isinstance ( right , Dist ) : return left ** right , left ** right else : output = numpy . ones ( xloc . shape ) left = left * output assert numpy . all ( left >= 0 ) , "root of negative number" indices = xloc > 0 output [ indices ] = numpy . log ( xloc [ indices ] ) output [ ~ indices ] = - numpy . inf indices = left != 1 output [ indices ] /= numpy . log ( left [ indices ] ) output = evaluation . evaluate_bound ( right , output , cache = cache ) output = left ** output output [ : ] = ( numpy . where ( output [ 0 ] < output [ 1 ] , output [ 0 ] , output [ 1 ] ) , numpy . where ( output [ 0 ] < output [ 1 ] , output [ 1 ] , output [ 0 ] ) , ) return output output = numpy . zeros ( xloc . shape ) right = right + output indices = right > 0 output [ indices ] = numpy . abs ( xloc [ indices ] ) ** ( 1 / right [ indices ] ) output [ indices ] *= numpy . sign ( xloc [ indices ] ) output [ right == 0 ] = 1 output [ ( xloc == 0 ) & ( right < 0 ) ] = numpy . inf output = evaluation . evaluate_bound ( left , output , cache = cache ) pair = right % 2 == 0 bnd_ = numpy . empty ( output . shape ) bnd_ [ 0 ] = numpy . where ( pair * ( output [ 0 ] * output [ 1 ] < 0 ) , 0 , output [ 0 ] ) bnd_ [ 0 ] = numpy . where ( pair * ( output [ 0 ] * output [ 1 ] > 0 ) , numpy . min ( numpy . abs ( output ) , 0 ) , bnd_ [ 0 ] ) ** right bnd_ [ 1 ] = numpy . where ( pair , numpy . max ( numpy . abs ( output ) , 0 ) , output [ 1 ] ) ** right bnd_ [ 0 ] , bnd_ [ 1 ] = ( numpy . where ( bnd_ [ 0 ] < bnd_ [ 1 ] , bnd_ [ 0 ] , bnd_ [ 1 ] ) , numpy . where ( bnd_ [ 0 ] < bnd_ [ 1 ] , bnd_ [ 1 ] , bnd_ [ 0 ] ) , ) return bnd_
Distribution bounds.

        Example:
            >>> print(chaospy.Uniform().range([-2, 0, 2, 4]))
            [[0. 0. 0. 0.]
             [1. 1. 1. 1.]]
            >>> print(chaospy.Pow(chaospy.Uniform(), 2).range([-2, 0, 2, 4]))
            [[0. 0. 0. 0.]
             [1. 1. 1. 1.]]
            >>> print(chaospy.Pow(chaospy.Uniform(1, 2), -1).range([-2, 0, 2, 4]))
            [[0.5 0.5 0.5 0.5]
             [1.  1.  1.  1. ]]
            >>> print(chaospy.Pow(2, chaospy.Uniform()).range([-2, 0, 2, 4]))
            [[1. 1. 1. 1.]
             [2. 2. 2. 2.]]
            >>> print(chaospy.Pow(2, chaospy.Uniform(-1, 0)).range([-2, 0, 2, 4]))
            [[0.5 0.5 0.5 0.5]
             [1.  1.  1.  1. ]]
            >>> print(chaospy.Pow(2, 3).range([-2, 0, 2, 4]))
            [[8. 8. 8. 8.]
             [8. 8. 8. 8.]]