Approximation PyPi Package

Summing two random variables and fitting them into a suitable distribution is often a challenging task. One well-known distribution that is difficult to sum exactly is the lognormal distribution. Many mathematicians have addressed this problem and developed approximation methods, even though an exact distribution may not be possible.

The creation of this package is inspired by the idea of encapsulating these approximation methods in a Python package while maintaining the user-friendly nature of the Python language. I started with two well-known approximation methods: Fenton-Wilkinson (1) and Schwartz-Yeh (2).

Additionally, I have included two simple functions: one for summing normal distributions and another for obtaining the distribution of the difference between two normal distributions. Another function is available to create a random sample using the Monte Carlo method for summed distributions.

The aim is to extend the package with methods from the literature that approximate combined distributions. This will allow users to easily apply these approximation methods without needing a complete understanding of the underlying techniques or the necessity of hard-coding.

Install

Dependencies

  1. scipy
  2. random

User installation

Functions

Fenton-Wilkinson Approximation

(1) Fenton, L. (1960). The sum of log-normal probability distributions in scatter transmission systems. IRE Transactions on communications systems, 8(1), 57-67.

The famous Fenton-Wilkinson approximation assumes that the first and second moments of the concatenated distribution are equal to the sum of the moments of the individual distributions. This function allows lognormal distributions from the scipy.stats package. It returns a scipy.stats.lognorm object, which represents the Fenton-Wilkinson approximated distribution for the summation of the given distributions.

Schwartz-Yeh Approximation (with table)

(2) Schwartz, S. C., & Yeh, Y. S. (1982). On the distribution function and moments of power sums with log‐normal components. Bell System Technical Journal, 61(7), 1441-1462.

Famous Schwartz-Yeh approximation focuses on exact expressions for the moments with two components. An iterative approach is used when there are more than two components. While calculating the moments of the log of summed random variables, the expressions become two-parameter functions. Therefore, Schwartz and Yeh also provided two tables for a certain range of Gaussian random variable values to facilitate the calculation of the output of related functions without complex limit and convergence analysis. This function allows lognormal distributions from the scipy.stats package. It returns a scipy.stats.lognorm object, which represents the Schwartz-Yeh approximated distribution for the summation of the given distributions.

Github project with full details

PyPi page