A Simple Algorithm for Converting Random Number Generator Outputs to Universal Distributions to Aid Teaching and Research in Modern Physical Chemistry

07 May 2024, Version 1
This content is a preprint and has not undergone peer review at the time of posting.

Abstract

Molecules and materials often display distributed heterogeneous properties. Modeling the behavior of a single molecule with these properties (e.g. via Monte-Carlo simulations) requires a rapid way to sample distributions of interest and describe how they evolve. Here, we pedagogically introduce a simple algorithm that converts evenly distributed random number generator outputs to any defined probability density function (PDF) called the Random Number Converter (RNC). We demonstrate a numerical approach to obtain cumulative distribution functions (CDFs) and utilize a binary search algorithm to circumvent the need for analytical inverse CDFs. This simple method is demonstrated for various distributions, including single-exponential and Gaussian distributions and non-standard PDFs, for which neither the CDF nor its inverse are analytically solvable. We then apply this algorithm to the rate analysis of catalytic turnover cycles and Fourier spectroscopy, enabling the study of complex reaction kinetics and retrospective interferometry analysis. Our algorithm and examples can be used to train undergraduates on the tools that underlay Monte Carlo methods and connect physical chemistry to standard computer science and statistics. We provide a MATLAB and Python module in the Supporting Information with customizable parameters.

Keywords

random number
random number generation
universal distribution shapes
probability density function
cumulative distribution function
RNG
CDF
PDF
statistical mechanics
physical chemistry education
Monte Carlo method
inverse transform sampling

Supplementary materials

Title
Description
Actions
Title
Supporting Information: A Simple Algorithm for Converting Random Number Generator Outputs to Universal Distributions to Aid Teaching and Research in Modern Physical Chemistry
Description
1. The presented RNC in MATLAB and Python with comments 2. Single-exponential decay distribution with analytical CDF and inv(CDF) 3. Marsaglia polar method which utilizes the Box-Muller transform 4. Analytical solutions to the cyclic chemical reaction (F1-ATPase model) 5. MATLAB script for the retrospective MZI Fourier spectroscopy simulation
Actions

Comments

Comments are not moderated before they are posted, but they can be removed by the site moderators if they are found to be in contravention of our Commenting Policy [opens in a new tab] - please read this policy before you post. Comments should be used for scholarly discussion of the content in question. You can find more information about how to use the commenting feature here [opens in a new tab] .
This site is protected by reCAPTCHA and the Google Privacy Policy [opens in a new tab] and Terms of Service [opens in a new tab] apply.