[Paper Review] General Purpose Convolution Algorithm in S4-Classes by means of FFT
This paper presents a general-purpose convolution algorithm for univariate probability distributions in R using FFT-based discrete Fourier transformation within S4 classes. It enables accurate, efficient convolution of arbitrary distributions—discrete, continuous, or mixed—by discretizing to a lattice, applying FFT, and smoothing results, with exact methods overloaded for special cases like normal or Poisson distributions.
Object orientation provides a flexible framework for the implementation of the convolution of arbitrary distributions of real-valued random variables. We discuss an algorithm which is based on the discrete Fourier transformation (DFT) and its fast computability via the fast Fourier transformation (FFT). It directly applies to lattice-supported distributions. In the case of continuous distributions an additional discretization to a linear lattice is necessary and the resulting lattice-supported distributions are suitably smoothed after convolution. We compare our algorithm to other approaches aiming at a similar generality as to accuracy and speed. In situations where the exact results are known, several checks confirm a high accuracy of the proposed algorithm which is also illustrated at approximations of non-central $χ^2$-distributions. By means of object orientation this default algorithm can be overloaded by more specific algorithms where possible, in particular where explicit convolution formulae are available. Our focus is on R package distr which includes an implementation of this approach overloading operator "+" for convolution; based on this convolution, we define a whole arithmetics of mathematical operations acting on distribution objects, comprising, among others, operators "+", "-", "*", "/", and "^".
Motivation & Objective
- To develop a unified, extensible framework for convolution of arbitrary univariate probability distributions in R using object-oriented programming.
- To enable accurate and efficient convolution of both discrete and continuous distributions through FFT-based numerical inversion.
- To provide a default algorithm that can be automatically overridden by exact methods when available (e.g., for normal or Poisson distributions).
- To support a full arithmetics of distribution objects, including +, -, *, /, and ^, with all four distribution functions (CDF, density, quantile, RNG) preserved.
- To ensure high accuracy and computational efficiency suitable for practical applications in actuarial science, robust statistics, and simulation.
Proposed method
- Discretize arbitrary distributions (discrete or continuous) onto a linear lattice to enable numerical computation.
- Apply the Fast Fourier Transform (FFT) to compute the characteristic function-based convolution via the Discrete Fourier Transform (DFT).
- Use inverse FFT to recover the convolved distribution in the original domain, followed by smoothing to reduce discretization artifacts.
- Leverage R's S4 class system to encapsulate distribution objects with full functionality (CDF, density, quantile, random deviates).
- Overload the '+' operator to dispatch to either the general FFT-based method or specialized exact methods (e.g., for normal or Poisson distributions).
- Control accuracy via global options (e.g., grid resolution and truncation quantiles) to balance precision and performance.
Experimental results
Research questions
- RQ1How can a general-purpose convolution algorithm be implemented in a way that supports arbitrary univariate distributions within an object-oriented framework?
- RQ2What is the trade-off between accuracy and computational efficiency when using FFT-based convolution with lattice discretization?
- RQ3Can the FFT-based method achieve sufficient accuracy for practical applications such as actuarial modeling or robust statistics?
- RQ4How does the performance and accuracy of the proposed FFT-based method compare to existing packages like 'actuar' or 'distr' with exact methods?
- RQ5To what extent can the S4 class system in R support a full arithmetics of distribution objects with consistent function propagation?
Key findings
- The FFT-based convolution method achieves high accuracy, with maximum absolute error in density approximations below 1.25e-3 even under fine discretization.
- The method is significantly faster than 'actuar' package's convolution: at 1.82% of the time for the same task, with a 100x speedup relative to 'actuar' in benchmarking.
- The default FFT method closely matches exact results, with median absolute error in density evaluation below 1e-5 and maximum error below 8e-6.
- The framework supports full distribution objects with all four components (CDF, density, quantile, RNG), enabling seamless arithmetic operations.
- The approach is robust across diverse distributions, including non-central chi-squared approximations, and performs well under extreme quantile truncation (1e-6).
- The implementation in the R package 'distr' enables practical use in advanced statistical applications such as robust estimation, risk modeling, and actuarial calculations.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.