Skip to contents

In order to run the directional inverse algorithm, we need to know approximately where the solution lies. This function finds a range of possible outcomes where the cdf evaluates to values (probabilities) contain the vector p, and therefore should come before the inversion algorithm begins.

Usage

encapsulate_p(distribution, p, direction)

Arguments

distribution

A distribution having access to a cdf.

p

Vector of values between 0 and 1 (inclusive).

direction

One of "left" for calculating left-inverse, or "right" for calculating right-inverse.

Value

A range of values containing the solutions to the left inverse of the CDF at p.

Note

If 0 or 1 are included in the vector p, one of the endpoints might be infinite.

Examples

d <- distribution(cdf = \(x) pmin(pmax(x, 0), 1))
distionary:::encapsulate_p(d, p = 1:9 / 10, direction = "left")
#> [1] -1  1