Abstract
Spreadsheet workbook contents are simple programs. Because of this, probabilistic programming techniques can be used to perform Bayesian inversion of spreadsheet computations. What is more, existing execution engines in spreadsheet applications such as Microsoft Excel can be made to do this using only built-in functionality. We demonstrate this by developing a native Excel implementation of both a particle Markov Chain Monte Carlo variant and black-box variational inference for spreadsheet probabilistic programming. The resulting engine performs probabilistically coherent inference over spreadsheet computations, notably including spreadsheets that include user-defined black-box functions. Spreadsheet engines that choose to integrate the functionality we describe in this paper will give their users the ability to both easily develop probabilistic models and maintain them over time by including actuals via a simple user-interface mechanism. For spreadsheet end-users this would mean having access to efficient and probabilistically coherent probabilistic modeling and inference for use in all kinds of decision making under uncertainty.
Introduction: Beyond Deterministic "What-If"
Spreadsheets are the ubiquitous "lingua franca" of modern data analysis. For decades, they have served as the primary tool for simulations and decision-making across finance, engineering, and science. However, traditional spreadsheets are fundamentally deterministic: users input assumptions, and the engine calculates a result. To perform "inverse" calculations—such as determining the distribution of input assumptions that likely produced an observed outcome—users typically must resort to manual trial-and-error or migrate their data to specialized environments like Python or R.
This research bridges that gap by transforming Microsoft Excel into a native Probabilistic Programming Language (PPL). By formalizing spreadsheet logic as a directed acyclic graph (DAG), the authors enable Bayesian inference directly within the workbook interface, allowing users to define uncertain parameters and observe actual data points to refine their models.
Formalizing the Spreadsheet as a Program
To enable probabilistic reasoning, the authors define an Abstract Spreadsheet Language. This formalization treats cells not just as containers for values, but as nodes in a functional program. Key innovations include:
- Elementary Random Processes (ERPs): Cells can contain distributions (e.g.,
GAUSSIAN,BETWEEN,CHOICE) rather than static values. - The
ACTUALStatement: This novel primitive allows users to "observe" a value. It signals to the inference engine that a specific cell's value is fixed, triggering the Bayesian inversion process to find the input distributions that best explain that observation. - Guaranteed Termination: By ensuring spreadsheets remain well-formed (free of circular references), the authors prove the underlying graph is a DAG, ensuring stable and predictable inference.
Native Inference Engines
Rather than relying on external runtimes, the system implements two primary inference algorithms as Excel Add-ins using Visual Basic (VB):
- Sequential Monte Carlo (SMC): A particle-based method that runs numerous parallel simulations of the spreadsheet to estimate the posterior distribution of uncertain variables.
- Black-Box Variational Inference (BBVI): An optimization-based approach. BBVI is particularly critical for spreadsheets because it can perform inference through "black-box" functions—such as Excel’s internal C++ code for
IRRor custom VBA scripts—where internal gradients are inaccessible.
Applications in Data Modeling
The system was evaluated on real-world tasks, such as modeling US GDP growth from 1950 to 1983. In this linear regression example, the engine infers the slope and intercept of growth based on historical data.
As shown in Figure 2, the user defines the model slope as a GAUSSIAN distribution. The ACTUAL function then links the model's predictions to the historical "Actuals" column. The BBVI engine achieved high accuracy, producing a slope mean ($μ = 0.098$) nearly identical to the ground truth ($μ = 0.099$).
Handling Black-Box Functions
A major strength of this approach is its ability to handle complex, pre-existing spreadsheet functions. Financial models often rely on built-in tools like IRR (Internal Rate of Return), which are computationally opaque to external PPLs.
Figure 5 illustrates a synthetic financial model where the engine performs inference through the IRR function. By using BBVI, the system treats IRR as a black box, successfully calculating the probability distributions of growth rates and dividend probabilities that align with observed cash flows.
Conclusion and Future Outlook
This work demonstrates that spreadsheets are "hidden" PPLs. By integrating Bayesian inference natively, spreadsheet applications can offer users "Goal Seek on steroids"—moving from finding a single deterministic point to understanding a full probability distribution of outcomes. While the current prototype faces performance limitations due to its Visual Basic implementation, it proves the feasibility of bringing sophisticated probabilistic modeling to the world's most popular data tool. Future work will focus on low-level optimization and refining the user interface to make Bayesian modeling intuitive for non-statisticians.
Summary updated