PaCAL: A Python Package for Arithmetic Computations with Random Variables

In this paper we present PaCAL, a Python package for arithmetical computations on random variables. The package is capable of performing the four arithmetic operations: addition, subtraction, multiplication and division, as well as computing many standard functions of random variables. Summary statistics, random number generation, plots, and histograms of the resulting distributions can easily be obtained and distribution parameter fitting is also available. The operations are performed numerically and their results interpolated allowing for arbitrary arithmetic operations on random variables following practically any probability distribution encountered in practice. The package is easy to use, as operations on random variables are performed just as they are on standard Python variables. Independence of random variables is, by default, assumed on each step but some computations on dependent random variables are also possible. We demonstrate on several examples that the results are very accurate, often close to machine precision. Practical applications include statistics, physical measurements or estimation of error distributions in scientific computations.

[1]  P. R. Nelson The algebra of random variables , 1979 .

[2]  Prakash P. Shenoy,et al.  Inference in hybrid Bayesian networks using mixtures of polynomials , 2011, Int. J. Approx. Reason..

[3]  R. Nelsen An Introduction to Copulas , 1998 .

[4]  Eric Jones,et al.  SciPy: Open Source Scientific Tools for Python , 2001 .

[5]  Andrew Thomas,et al.  WinBUGS - A Bayesian modelling framework: Concepts, structure, and extensibility , 2000, Stat. Comput..

[6]  Donald Ervin Knuth,et al.  The Art of Computer Programming , 1968 .

[7]  Mark E. J. Newman,et al.  Power-Law Distributions in Empirical Data , 2007, SIAM Rev..

[8]  Andrew G. Glen,et al.  APPL: A Probability Programming Language , 2001 .

[9]  David Huard,et al.  PyMC: Bayesian Stochastic Modelling in Python. , 2010, Journal of statistical software.

[10]  Szymon Jaroszewicz,et al.  Arithmetic Operations on Independent Random Variables: A Numerical Approach , 2012, SIAM J. Sci. Comput..

[11]  John D. Hunter,et al.  Matplotlib: A 2D Graphics Environment , 2007, Computing in Science & Engineering.

[12]  Guido van Rossum,et al.  Python Programming Language , 2007, USENIX Annual Technical Conference.

[13]  Lloyd N. Trefethen,et al.  An Extension of MATLAB to Continuous Functions and Operators , 2004, SIAM J. Sci. Comput..

[14]  Philip Rabinowitz,et al.  Methods of Numerical Integration , 1985 .

[15]  J. Hoffmann-jorgensen,et al.  Probability with a View Toward Statistics , 1994 .

[16]  J. Boyd Exponentially convergent Fourier-Chebshev quadrature schemes on bounded and infinite intervals , 1987 .

[17]  William Feller,et al.  An Introduction to Probability Theory and Its Applications , 1951 .

[18]  Stephen Wolfram,et al.  The Mathematica Book , 1996 .

[19]  Lloyd N. Trefethen,et al.  Barycentric Lagrange Interpolation , 2004, SIAM Rev..

[20]  Stefan Behnel,et al.  Cython: The Best of Both Worlds , 2011, Computing in Science & Engineering.

[21]  Robert C. Williamson,et al.  Probabilistic arithmetic. I. Numerical methods for calculating convolutions and dependency bounds , 1990, Int. J. Approx. Reason..

[22]  J. Waldvogel Fast Construction of the Fejér and Clenshaw–Curtis Quadrature Rules , 2006 .

[23]  Lloyd N. Trefethen,et al.  Is Gauss Quadrature Better than Clenshaw-Curtis? , 2008, SIAM Rev..

[24]  Konrad Hinsen,et al.  Numerical Python , 1996 .

[25]  R Core Team,et al.  R: A language and environment for statistical computing. , 2014 .