#+TITLE: CharacteristicInvFourier #+AUTHOR: Tomás Lobão de Almeida #+EMAIL: tomas.almeida@astrolabium.io

  • Summary This small package provides a simple way to obtain a probability density function and/or cumulative density function from a characteristic function defined by the user, by numerically approximating its inverse Fourier transform. Currently, only a methodology that uses FFTW is provided. This methodology can be useful but it's not guaranteed to provide accurate results due to numerical errors; make sure you analyze the output and compare it with your expectations.

** Exported Functions

*** pdf_invfourier_fft Returns the pdf of the provided characteristic function. It's a continuous function, as it interpolates the results of the integrated gridpoints.

Arguments:

  • Φ(Function): the characteristic function to operate on;

Keyword arguments:

  • npower(Int): the power used to calculate gridpoint = 2^npower (default 15);
  • σrule(Real): multiplying factor for calculating integration interval as mean +- σrule * std (default 10);
  • toldiff(Real): used for approximating mean and std by finite differences (default 1e-4);
  • xbounds(Union{Nothing, Tuple{Real, Real}, Vector{Real}}): pass a collection where the first element is the lower boundary of the integration interval and the last element is the upper boundary, if left empty the integration interval will be automatically decided using the method with σrule;
  • inf_atzero(Bool): if the real part of the limit of your characteristic function when u goes to infinity is not zero, you can set this as true and it will rescale the calculations with a big constant to try to minimize numerical errors.

*** cdf_invfourier_fft Returns the cdf of the provided characteristic function. It's a continuous function, as it interpolates the results of the integrated gridpoints.

Arguments:

  • Φ(Function): the characteristic function to operate on;

Keyword arguments:

  • npower(Int): the power used to calculate gridpoint = 2^npower (default 15);
  • σrule(Real): multiplying factor for calculating integration interval as mean +- σrule * std (default 10);
  • toldiff(Real): used for approximating mean and std by finite differences (default 1e-4);
  • xbounds(Union{Nothing, Tuple{Real, Real}, Vector{Real}}): pass a collection where the first element is the lower boundary of the integration interval and the last element is the upper boundary, if left empty the integration interval will be automatically decided using the method with σrule;
  • inf_atzero(Bool): if the real part of the limit of your characteristic function when u goes to infinity is not zero, you can set this as true and it will rescale the calculations with a big constant to try to minimize numerical errors.
  • References This code is based on the following:
  • Viktor Witkovský (2016) - Numerical inversion of a characteristic function: An alternative tool to form the probability distribution of output quantity in linear measurement models
  • https://github.com/witkovsky/CharFunTool
  • Examples

#+begin_src julia :eval no using CharacteristicInvFourier

k = 9.0 θ = 0.5 Φ_gamma(u) = (1 - 1im * u * θ) ^ (-k)

pdf_gamma = pdf_invfourier_fft(Φ_gamma) cdf_gamma = cdf_invfourier_fft(Φ_gamma) #+end_src

  • Status More methodologies for integrating the characteristic function (based on different quadrature methods) would be the next step for improving this package, in order to diminish numerical errors that seem prevalent with using FFT. The current CI pipeline compares analytical and integrated results for the Gaussian, exponential and gamma distributions. We see can by the error tolerances (selected empirically) that this methodology has problems with the pdf's of the last two distributions; they are undefined at zero and this might be causing numerical errors.