# Computes Numeric Fourier Integrals

Computes Fourier integrals of functions of one and two variables using the Fast Fourier transform. The Fourier transforms must be evaluated on a regular grid.

Guillermo Basulto-Elias

This is a package in R to numerically calculate Fourier-type integrals of multivariate functions with compact support evaluated at regular grids. Specifically, integrals of the type

where,

Common values for r are -1, 0 and -1, while common values for s are -2\pi, -1, 1 and 2\pi. For example, if f is a density function, s = 1 and r = 1 could be used to obtain the characteristic function of f. Conversely, if f is the characteristic function of a probability density function, then r = -1 and s = -1 could be used to recover the density.

The implementation of this algorithm is the one described in Inverarity (2002), Fast Computation of multidimensional Integrals.

Some examples (also found in documentation).

library(fourierin)                                         # Compute integralout <- fourierin(f = function(t) exp(-t^2/2),                 a = -5, b = 5, c = -3, d = 3,                 r = -1, s = -1, resol = 64)grid <- out$w # Extract grid and valuesvalues <- Re(out$values) plot(grid, values, type = "l", col = 3, xlab = "x", ylab = "f(x)")lines(grid, dnorm(grid), col = 4)legend("topleft", legend = c("True", "Recovered"), col = c(4, 3),      lwd = 1)

library(fourierin)                                        # Compute integralshape <- 5rate <- 3out <- fourierin(f = function(t) dgamma(t, shape, rate),                 a = -0, b = 8, c = -5, d = 5,                 r = 1, s = 1, resol = 64)grid <- out$w # Extract gridre_values <- Re(out$values)             # Real valuesim_values <- Im(out\$values)             # Imag values                                         # Now compute the real and                                        # imaginary true values of the                                        # characteric function.true_cf <- function(t, shape, rate) (1 - 1i*t/rate)^-shapetrue_re <- Re(true_cf(grid, shape, rate))true_im <- Im(true_cf(grid, shape, rate))                                         # Compare them. We can see a                                        # slight discrepancy on the                                        # tails, but that is fixed                                        # when resulution is                                        # increased.plot(grid, re_values, type = "l", col = 3, xlab = "t",     ylab = expression(paste("Re ", phi(t))))lines(grid, true_re, col = 4)legend("topright", legend = c("True", "Recovered"), col = c(4, 3),      lwd = 1)

                                        # Same hereplot(grid, im_values, type = "l", col = 3, xlab = "t",     ylab = expression(paste("Im ", phi(t))))lines(grid, true_im, col = 4)legend("topright", legend = c("True", "Recovered"), col = c(4, 3),      lwd = 1)

# Version 0.1.2

Patch: microbenchmark is now used only conditionally.

# Version 0.1.1

This first version of the package includes univariate and bivariate Fourier-type integrals.

# Reference manual

install.packages("fourierin")

0.2.2 by Guillermo Basulto-Elias, 4 months ago

http://github.com/gbasulto/fourierin

Report a bug at https://github.com/gbasulto/fourierin/issues

Browse source code at https://github.com/cran/fourierin

Authors: Guillermo Basulto-Elias

Documentation:   PDF Manual