Math, Ops and Summary group generic methods for
errors objects with support for automatic uncertainty propagation (see
groupGeneric for a comprehensive list of available methods).
Usage
# S3 method for class 'errors'
Math(x, ...)
# S3 method for class 'errors'
Ops(e1, e2)
# S3 method for class 'errors'
Summary(..., na.rm = FALSE)Details
Math
The sign method returns a numeric value without uncertainty. floor,
ceiling, trunc, round and signif add the rounding
error to the original uncertainty. lgamma, gamma, digamma and
trigamma are not implemented. The rest of the methods propagate the
uncertainty as expected from the first-order Taylor series method.
Ops
Boolean operators drop the uncertainty (showing a warning once) and operate on the
numeric values. The rest of the operators propagate the uncertainty as expected from
the first-order Taylor series method. Any numeric operand is automatically
coerced to errors (showing a warning once) with no uncertainty.
Examples
x <- set_errors(1:3, 0.1)
exp(x)
#> Errors: 0.2718282 0.7389056 2.0085537
#> [1] 2.718282 7.389056 20.085537
log(x)
#> Errors: 0.10000000 0.05000000 0.03333333
#> [1] 0.0000000 0.6931472 1.0986123
cumsum(x)
#> Errors: 0.1000000 0.1414214 0.1732051
#> [1] 1 3 6
cumprod(x)
#> Errors: 0.1000000 0.2236068 0.7000000
#> [1] 1 2 6
y <- set_errors(4:6, 0.2)
x / sqrt(y) + y * sin(x)
#> Errors: 0.3083702 0.2314527 0.5532258
#> [1] 3.865884 5.440914 2.071465
# numeric values are automatically coerced to errors
x^2
#> Warning: In 'Ops' : non-'errors' operand automatically coerced to an 'errors' object with no uncertainty
#> Errors: 0.2 0.4 0.6
#> [1] 1 4 9
# boolean operators drop uncertainty
y > x
#> [1] TRUE TRUE TRUE
c(min(x), max(x))
#> [1] 0.9 3.1
range(x)
#> [1] 0.9 3.1
sum(y)
#> 15.0(3)
prod(y)
#> 120(9)