Capital budgeting is a necessary exercise that often gets neglected in the analytics domain. While Excel has add-ons for Monte Carlo simulations, running these analyses on Google Sheets or macOS Numbers is nearly impossible. This article demonstrates how to use Python for robust capital budgeting with Monte Carlo simulations.
The Problem
Traditional capital budgeting relies on single-point estimates for cash flows. But real-world variables like costs, revenues, and growth rates are uncertain. A Monte Carlo simulation addresses this by:
- Defining probability distributions for each variable
- Sampling from these distributions thousands of times
- Calculating the outcome (NPV, IRR) for each sample
- Analyzing the distribution of results
A Practical Example: Cloud Migration
Consider a common challenge many tech companies face: Should we migrate our on-premise workloads to the cloud?
We need to compare:
- Current cash flows for running, maintaining, and expanding on-premise infrastructure
- Projected cash flows for cloud migration and ongoing cloud costs
Figure 1: Cash flow structure for the cloud migration analysis. Each row represents a cost category with Year 0 (initial investment) and projected years. Negative values indicate costs, positive values indicate savings.
Key Financial Metrics
Net Present Value (NPV)
NPV calculates the present value of future cash flows, discounted by a hurdle rate:
| |
Internal Rate of Return (IRR)
IRR is the discount rate that makes NPV equal to zero—essentially, the return above breakeven:
| |
Setting Up the Monte Carlo Simulation
Define Probability Distributions
Each uncertain variable gets a probability distribution based on domain expertise:
| |
Run the Simulation
| |
Analyze Results
| |
Sample Output:
NPV Statistics:
Mean: $847,234
Median: $823,156
Std Dev: $312,456
5th Percentile: $298,412
95th Percentile: $1,423,891
Probability NPV > 0: 94.2%
IRR Statistics:
Mean: 28.3%
Probability IRR > Hurdle Rate: 91.7%
This output tells us the cloud migration has a 94.2% probability of positive NPV and a 91.7% chance of exceeding our 10% hurdle rate—a strong investment case.
Figure 2: Complete 10-year cash flow projection from a single Monte Carlo iteration. The bottom rows show cumulative cash flows and after-tax values used to calculate NPV and IRR.
Visualizing the Results
| |
The resulting histograms show the full distribution of possible outcomes, making it easy to visualize the range of scenarios and communicate risk to stakeholders.
Figure 3: NPV distribution at the 3-year mark from 100,000 Monte Carlo iterations. The distribution centers around $1.35M with a roughly normal shape, indicating consistent positive returns in the short term.
Figure 4: NPV distribution at the 10-year mark. The mean shifts to approximately $4M, demonstrating how the investment value compounds over time. The wider spread reflects increased uncertainty over longer horizons.
Making the Decision
With Monte Carlo results, you can make informed decisions:
| Scenario | Recommendation |
|---|---|
| P(NPV > 0) > 90% | Strong case for investment |
| P(NPV > 0) between 50-90% | Proceed with caution, consider risk tolerance |
| P(NPV > 0) < 50% | Investment likely unfavorable |
Additionally, compare the IRR distribution against your hurdle rate to understand the probability of achieving your minimum required return.
Extending the Analysis
This template extends beyond cloud migration. Use it for:
- Factory development decisions
- Data compression cost savings analysis
- New product launch feasibility
- Equipment replacement timing
- R&D investment evaluation
The complete notebook is available on GitHub.
Conclusion
Monte Carlo simulation transforms capital budgeting from a single-point estimate exercise into a probabilistic analysis. By understanding the full distribution of possible outcomes, you can:
- Quantify uncertainty in investment decisions
- Communicate risk to stakeholders
- Make decisions aligned with your organization’s risk tolerance
- Identify which variables have the greatest impact on outcomes
Python provides all the tools needed for sophisticated financial analysis without relying on expensive Excel add-ons or limited spreadsheet capabilities.
Originally published on CodeX