| interval | R Documentation |
Calculates the range [\min f, \max f] of a model f(x_1, \ldots, x_N) when each input variable is only known to lie in an interval [A_i, B_i]. The function is evaluated on a grid over the box of input intervals ("vertex" or "grid" method), and the grid minimum and maximum are refined by box-constrained optimisation. Unlike naive interval arithmetic, the result is not inflated by the dependency problem.
interval(df, expr, seq = 10, plot = TRUE, refine = TRUE, maxgrid = 1E6)
## S3 method for class 'interval'
print(x, ...)
df |
a data frame or matrix with two rows, the lower limits |
expr |
an expression, such as |
seq |
the number of grid points per variable from |
plot |
logical. If |
refine |
logical. If |
maxgrid |
the maximal number of grid points |
x |
an object of class |
... |
not used. |
Interval arithmetic and the dependency problem. For two intervals [x_1, x_2] and [y_1, y_2], the basic operations \circ \in \{+, -, \cdot, /\} of interval arithmetic are
[x_1, x_2] \circ [y_1, y_2] = [\min(x_i \circ y_j), \max(x_i \circ y_j)], \quad i, j \in \{1, 2\}
(for division, 0 \notin [y_1, y_2]). Applied operation by operation, this overestimates the range when a variable occurs more than once in an expression, because each occurrence is treated as an independent variable (dependency problem): e.g., x - x^2 with x \in [0, 1] gives [0, 1] - [0, 1] = [-1, 1], while the true range is [0, 0.25].
Vertex and grid method. interval avoids this by evaluating f as a whole. With seq = 2, f is evaluated at the 2^N vertices of the box (all combinations of the interval limits); this gives the exact range if f is monotone in each variable. If not, the extrema may lie inside the box: a larger seq evaluates f on a finer grid (seq^N points, with 0 added to intervals containing zero, e.g. for even powers), and refine = TRUE refines the grid minimum and maximum by bounded optimisation.
Inner approximation. The result is the range of the evaluated points and optimisation results, which can only be narrower than (or equal to) the true range: it is an inner approximation, not a guaranteed enclosure as in rigorous interval arithmetic. For functions with several local extrema, use a finer grid. Grid points where f is not finite (outside its domain) are ignored with a warning.
An object of class interval: a vector with the elements lower and upper, and the attributes argmin and argmax (the input values at the extrema) and ngrid (the number of grid points).
Andrej-Nikolai Spiess
Interval arithmetic and the dependency problem:
Introduction to Interval Analysis.
Moore RE, Kearfott RB, Cloud MJ.
SIAM, Philadelphia (2009).
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1137/1.9780898717716")}
Comparison to Monte Carlo and error propagation:
Interval arithmetic in power flow analysis.
Wang Z, Alvarado FL.
IEEE Transactions on Power Systems (1992), 7: 1341-1349.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/59.207353")}
Computer implementation:
Interval arithmetic: From principles to implementation.
Hickey T, Ju Q, Van Emden MH.
Journal of the ACM (2001), 48: 1038-1068.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1145/502102.502106")}
Complete interval arithmetic and its implementation on the computer.
Kulisch UW.
In: Numerical Validation in Current Hardware Architectures. Cuyt A, Kraemer W, Luther W, Markstein P (Eds.). Springer (2009), Lecture Notes in Computer Science 5492: 7-26.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/978-3-642-01591-5")}
propagate, makeDat
## Example 1: even power of an interval containing zero: [0, 1], not [-1, 1].
interval(data.frame(x = c(-1, 1)), expression(x^2))
## Example 2: a nonlinear model, monotone in each variable:
## the vertices (seq = 2) give the exact range.
EXPR2 <- expression(Cf * sqrt((520 * H * P)/(M * (Temp + 460))))
H <- c(64, 65); M <- c(16, 16.2); P <- c(361, 365); Temp <- c(165, 170); Cf <- c(38.4, 38.5)
DAT2 <- makeDat(EXPR2)
interval(DAT2, EXPR2, seq = 2)
## Example 3: body mass index.
EXPR3 <- expression(m/h^2)
m <- c(79.5, 80.5); h <- c(1.795, 1.805)
DAT3 <- makeDat(EXPR3)
interval(DAT3, EXPR3)
## Example 4: minimum inside the interval. For x in [-2, 1], naive interval arithmetic gives
## [0, 4] - [-2, 1] + 1 = [0, 7] (or [-2, 7] if x^2 is computed as x * x);
## the true range is [0.75, 7].
EXPR4 <- expression(x^2 - x + 1)
x <- c(-2, 1)
DAT4 <- makeDat(EXPR4)
interval(DAT4, EXPR4, seq = 2, refine = FALSE) ## vertices and 0 only: [1, 7]
interval(DAT4, EXPR4, seq = 2) ## refined: [0.75, 7]
curve(x^2 - x + 1, -2, 1)
## Example 5: dependency problem. Naive interval arithmetic gives
## [0, 1] - [0, 1] = [-1, 1]; the true range is [0, 0.25].
EXPR5 <- expression(x - x^2)
x <- c(0, 1)
DAT5 <- makeDat(EXPR5)
interval(DAT5, EXPR5, seq = 2, refine = FALSE) ## vertices only: [0, 0]
interval(DAT5, EXPR5) ## [0, 0.25]
curve(x - x^2, 0, 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.