A first lab entry: one small decision, the code behind it, and the question that matters most. How sure do you need to be?
Published
December 3, 2026
Illustrative example
The numbers below are made up to show the method. No course or client data is used.
The question
A pharmacy manager hears that a supplier may have problems next month. Should they order extra stock now, or hold?
Data can tell us what each outcome is worth. It can’t tell us, on its own, how likely the supply shock is. That part is a judgement. Decision analysis makes that judgement explicit, so it can be discussed, challenged and improved.
The decision, written down
options = {"Order extra stock": {"shock": 4200, "no_shock": -600},"Hold": {"shock": -5000, "no_shock": 800},}p_shock =0.25# a stated judgement, not a measured factdef expected_value(outcomes, p):return p * outcomes["shock"] + (1- p) * outcomes["no_shock"]for name, outcomes in options.items():print(f"{name:<18} EV = £{expected_value(outcomes, p_shock):,.0f}")
Order extra stock EV = £600
Hold EV = £-650
At a 25% chance of a shock, ordering extra stock looks better. But the more useful question is a different one.
How sure do we need to be?
Instead of arguing about whether the chance is 20% or 30%, we can find the point where the decision flips.
Show the chart code
import numpy as npimport matplotlib.pyplot as pltplt.rcParams.update({"font.family": "sans-serif", "axes.spines.top": False,"axes.spines.right": False, "axes.edgecolor": "#9AA6B0"})p = np.linspace(0, 0.5, 200)order = [expected_value(options["Order extra stock"], x) for x in p]hold = [expected_value(options["Hold"], x) for x in p]o, h = options["Order extra stock"], options["Hold"]crossover = (h["no_shock"] - o["no_shock"]) / ( (o["shock"] - o["no_shock"]) - (h["shock"] - h["no_shock"]))fig, ax = plt.subplots(figsize=(7, 3.8))ax.plot(p, order, color="#0F5C6E", lw=2.2, label="Order extra stock")ax.plot(p, hold, color="#B5651D", lw=2.2, label="Hold")ax.axhline(0, color="#E2E6EA", lw=1)ax.axvline(crossover, color="#5E6B75", ls="--", lw=1)ax.annotate(f"Decision flips at p ≈ {crossover:.0%}", xy=(crossover, 0), xytext=(crossover +0.02, -1500), color="#1E2A33", arrowprops=dict(arrowstyle="-", color="#5E6B75"))ax.axvline(p_shock, color="#0F5C6E", lw=1, alpha=.35)ax.text(p_shock +0.006, 1300, "our judgement: 25%", color="#0F5C6E", fontsize=9)ax.set_xlabel("Judged chance of a supply shock")ax.set_ylabel("Expected value (£)")ax.xaxis.set_major_formatter(plt.FuncFormatter(lambda v, _: f"{v:.0%}"))ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda v, _: f"£{v:,.0f}"))ax.legend(frameon=False, loc="upper left")fig.tight_layout()fig.savefig("thumbnail.png", dpi=150)plt.show()
Figure 1: Expected value of each option as the judged chance of a supply shock changes. Left of the crossover, hold. Right of it, order.
The decision flips at about a 13% chance of a shock. So the team doesn’t need to agree on an exact number. They only need to agree that the risk is above roughly one in eight. That is a much easier, and much better, conversation to have before the crunch arrives.
What I’d do differently
Replace the made-up values with real margins and holding costs.
Add a third option, such as a partial order, which often beats both extremes.
Ask several stakeholders for their own estimate of the chance, and show where they disagree.
Why this matters
Data analytics gives us the values in the tree. Decision analysis gives us the conversation about the uncertainty. Together they tell us not just what to do, but how confident we need to be, and when to look again.