Learn R Programming

docopulae (version 0.2.1)

nint_transform: Transform Integral

Description

nint_transform applies monotonic transformations to some integrand and space. A common use case is to apply the probability integral transform, or to transform infinite limits to finite ones.

Usage

nint_transform(f, space, dIdcs, trans, infZero = 0)

Arguments

f
function(x, ...), the integrand.
space
some space.
dIdcs
an integer vector of indices, the dimensions to transform.
trans
either the name of some builtin transformation or list(g=function(x), gij=function(y)) where g(x) = y and gij evaluates to the column matrix of gi(y) = x and its first derivative with respect to y<
infZero
the value to return if the jacobian is infinite and f returns 0.

Value

  • nint_transform returns a named list containing the transformed integrand and space.

Details

If the transformation is vector valued, that is y = c(y1, ..., yn) = g(c(x1, ..., xn)), then each component of y shall exclusively depend on the corresponding component of x. So y[i] = g[i](x[i]) for some implicit function g[i].

Builtins:

  • tan:g(x) = atan(x) = y
  • ratio:g(x) = x/abs(x + sign(x))= y withsign(0) == 1

See Also

nint_integrate, nint_space, fisherI

Examples

Run this code
## builtins
f = sin
s = nint_space(nint_intvDim(pi/4, 3*pi/4))
nint_integrate(f, s)

tt = nint_transform(f, s, 1, 'tan')
tt$space
nint_integrate(tt$f, tt$space)

tt = nint_transform(f, s, 1, 'ratio')
tt$space
nint_integrate(tt$f, tt$space)


## probability integral transform
tt = nint_transform(f, s, 1, list(
    g=pnorm,
    gij=function(x) { t1 = qnorm(x); cbind(t1, 1/dnorm(t1)) })
)
tt$space
nint_integrate(tt$f, tt$space)


## infinite limitis
f = function(x) prod(1/(1 + x**2))
s = nint_space(nint_intvDim(-1, Inf),
               nint_intvDim(-Inf, Inf))
s

nint_integrate(f, s) # stats::integrate takes care of Inf limits

tt = nint_transform(f, s, 1:2, 'tan')
tt$space
nint_integrate(tt$f, tt$space)

tt = nint_transform(f, s, 1:2, 'ratio')
tt$space
nint_integrate(tt$f, tt$space)

## probability integral transform
tt = nint_transform(f, s, 1:2, list(
    g=pnorm,
    gij=function(x) { t1 = qnorm(x); cbind(t1, 1/dnorm(t1)) })
)
tt$space
#nint_integrate(tt$f, tt$space) # Do you dare?

## The probability integral transform was used many times with fisherI,
## always with great success and considerable gains.
## It might be stats::integrate; see nint_integrateNCube

Run the code above in your browser using DataLab