We’ve all been there: A stakeholder asks for a delivery date, and the team, armed with their intuition and perhaps some historical velocity data, comes up with a number. But what if that number is only a rough estimate, ignoring the uncertainties inherent in software development?
What if we could offer a more nuanced, data-driven forecast that acknowledges the intrinsic variability of Agile projects? This is where Monte Carlo simulations provide a powerful tool for probabilistic planning and forecasting.
Table of contents
- A Brief History: From Nuclear Physics to Agile Planning
- The Cone of Uncertainty: A Familiar Analogy
- What is a Monte Carlo simulation?
- Why use Monte Carlo simulations in Agile?
- How to Use Monte Carlo Simulations for Agile Forecasting: A Practical Example
- Developing a Probabilistic Roadmap: An Example of Release Planning
- Conclusion
A Brief History: From Nuclear Physics to Agile Planning
Before we dive into the “how,” let’s take a quick look at the “why.”
The Monte Carlo method isn’t a new Agile technique. It has its roots in nuclear physics, developed by John von Neumann and Stanislaw Ulam in the 1940s. During the Manhattan Project, they faced complex problems that were too difficult to solve analytically.
Their solution? Use randomness! They named it after the famous gambling destination, Monaco, because the method relies on the same principles as randomness. They used repeated random sampling to obtain numerical results—a technique that has proven incredibly useful for modelling complex systems. We can harness this same principle, the power of repeated random sampling, in Agile.
The Cone of Uncertainty: A Familiar Analogy
Think about weather forecasting, especially hurricane predictions. Meteorologists don’t give you a single point on a map where the hurricane will make landfall. Instead, they show you a “cone of uncertainty.” This cone represents all possible paths the hurricane could take, with the most likely path in the center. The wider the cone, the greater the uncertainty. This is a perfect example of probabilistic forecasting.
They use complex models and simulations (often incorporating Monte Carlo methods) to generate thousands of possible hurricane paths, each with a certain probability. This gives them a much more realistic picture of the potential risks. Like hurricane paths, software development projects are subject to many variables that make accurate predictions impossible. Monte Carlo simulations provide our own “cone of uncertainty” for project timelines and deliverables.
What is a Monte Carlo simulation?
Imagine you’re trying to predict how long it will take to build a complex Lego castle. You could try estimating based on your past Lego building experiences, but that assumes everything will go exactly as planned.
A Monte Carlo simulation takes a different approach. It runs thousands of virtual “Lego building sessions,” each with slightly different build speeds based on your past performance. The result isn’t a single number but a range of possible completion times, each with an attached probability.
For example, you might find a 50% chance of completing in 10 days, a 75% chance of completing in 12 days, and a 90% chance of completing in 15 days. This gives you a much clearer picture of the project’s potential trajectory.
In Agile, we can apply this same principle to velocity forecasting, story point estimation, or even delivery date prediction. Instead of relying on a point estimate, we use historical data to simulate possible outcomes, giving us a probabilistic forecast.
Why use Monte Carlo simulations in Agile?
- Embrace uncertainty: Agile development is inherently unpredictable. Monte Carlo simulations acknowledge this uncertainty, providing a more realistic view of potential outcomes.
- Data-driven decisions: These simulations provide data to support sprint planning, release planning, and road mapping decisions.
- Improved communication: Probabilistic forecasts facilitate more transparent communication with stakeholders by presenting a range of possibilities rather than a single number.
- Increased Confidence: Understanding the range of potential outcomes increases confidence in the team’s ability to deliver, even if the exact date remains uncertain.
- Focus on Value: By understanding probability, teams can better focus on delivering value incrementally with more certainty.
How to Use Monte Carlo Simulations for Agile Forecasting: A Practical Example
Let’s say your team’s historical sprint velocities are: 10, 12, 8, 15, 20, 11. Here’s how you might use a Monte Carlo simulation:
- Collect Data: Collect your historical velocity data.
- Choose a tool: Use a spreadsheet (like Excel or Google Sheets), a dedicated Monte Carlo simulation tool, or even write a simple Python script. (See the example below)
- Run the simulation: The simulation will randomly sample your historical velocities to create thousands of possible future sprint outcomes.
- Analyse the results: Examine the distribution of results. What are the probabilities of reaching different velocity ranges?
- Communicate the forecast: Share the probabilistic forecast with stakeholders, explaining possible outcomes and their associated probabilities.
import numpy as np
import matplotlib.pyplot as plt
historical_velocity = [10, 12, 8, 15, 20, 11]
num_simulations = 10000
num_future_sprints = 5
simulated_velocities = []
for _ in range(num_simulations):
future_velocities = np.random.choice(historical_velocity, size=num_future_sprints, replace=True)
simulated_velocities.append(np.sum(future_velocities))
simulated_velocities = np.array(simulated_velocities)
percentiles = np.percentile(simulated_velocities, [10, 50, 90])
print(f'10th Percentile: {percentiles[0]}')
print(f'Median Velocity (50th Percentile): {percentiles[1]}')
print(f'90th Percentile: {percentiles[2]}')
plt.hist(simulated_velocities, bins=50, density=True, alpha=0.7, label="Simulated Velocities")
plt.axvline(percentiles[0], color='r', linestyle='--', label='10th Percentile')
plt.axvline(percentiles[1], color='b', linestyle='-', label='50th Percentile (Median)')
plt.axvline(percentiles[2], color='g', linestyle='--', label='90th Percentile')
plt.xlabel("Cumulative Velocity")
plt.ylabel("Probability Density")
plt.title("Monte Carlo Simulation of Future Velocity")
plt.legend()
plt.show()
Developing a Probabilistic Roadmap: An Example of Release Planning
Let’s say you need to launch a new version of your product. You’ve estimated that the remaining work requires approximately 60 story points. We can create a probabilistic roadmap for the release using the same historical velocity data (10, 12, 8, 15, 20, 11).
Simulate multiple sprints: Run the Monte Carlo simulation, but this time, instead of just looking at 5 sprints, simulate enough sprints to cover the estimated story points. We don’t know how many sprints this will take, so the simulation will help us determine the probability.
Calculate release probability: For each simulation run, determine how many sprints it took to reach or exceed 60 story points. This gives you a distribution of possible release times (in sprints).
Determine confidence intervals: Analyze the distribution of release times. For example:
- “We are 80% confident that we will launch the new version within 6 sprints.”
- “There’s a 50% chance we’ll launch within 5 sprints.”
- “There’s a 95% chance it won’t take more than 7 sprints.”
Communicate with stakeholders: Present these probabilistic release dates to stakeholders. Instead of a fixed date, you provide a range of possibilities with associated confidence levels, allowing for more realistic expectations and better planning.
Example communication: “Based on our historical performance and current estimates, we are 80% confident that we can launch the new version within 6 sprints. While we could launch earlier, this provides a reasonable timeframe for planning purposes. We will continue to monitor our progress and update you if anything changes.”
This approach offers several advantages:
- Transparency: Stakeholders understand the uncertainty involved and are less likely to be surprised by delays.
- Flexibility: The roadmap can be adjusted based on progress and changing priorities.
- Data-driven decisions: Release planning is based on data, not guesswork.
Conclusion
Monte Carlo simulations offer a powerful way to move beyond point estimates and embrace the uncertainty inherent in Agile. Providing a range of possible outcomes enables more informed decision-making, better communication with stakeholders, and increased confidence in the team’s ability to deliver value. So, cast your crystal ball, embrace the power of probability, and start forecasting confidently!
A key takeaway for the reader: Consider how you currently plan in your Agile projects. Could Monte Carlo simulations offer a more realistic and helpful approach? Experiment with the provided Python code or explore other available tools. Start small, perhaps!
References
- D. Vacanti, When Will It Be Done?: Lean-Agile Forecasting to Answer Your Customers’ Most Important Question, 2020
- Monte Carlo forecasting explained
- Monte Carlo forecasting Scrum
- Probabilistic Forecasting and Flow with Scrum
- Forecasting techniques
- Wikipédia Monte Carlo method
