Decision Analysis¶
Qahwa House has been offered a site at a winter festival in Riyadh, for an 80-day season. It can open a big kiosk, a small kiosk, or no kiosk at all. The big kiosk earns far more if the crowds come, and loses far more if they do not, and nobody knows yet how many visitors the venue will draw. A market-research firm offers a footfall survey for 25,000 SAR. The owner has to decide whether to buy the survey, and which kiosk to open.
This reading turns that situation into a decision model and solves it four ways: with rules that ignore probabilities, with expected monetary value, with a decision tree that includes the survey, and with a utility function for an owner who dislikes big losses.
After this reading you can:
write a decision as a payoff table of alternatives and states of the world;
apply the maximax, maximin and minimax-regret criteria, and say what attitude each one encodes;
compute expected monetary values and test how sensitive the choice is to a probability;
build a decision tree in Python and fold it back;
update probabilities with Bayes’ rule and compute the value of perfect and of sample information;
use an exponential utility function, a certainty equivalent and a risk premium for a risk-averse decision maker.
The data¶
One small table holds two decisions; this reading uses the kiosk case (the lab uses cold_brew).
| Column | Meaning |
|---|---|
case | which decision: kiosk (the reading) or cold_brew (the lab) |
alternative | an option the decision maker can choose |
state | a state of the world: what may happen, which nobody controls |
prior | the probability of the state, before any new information |
p_positive | the probability that a study (a survey or a pilot) gives a positive result if this state is the true one |
units, unit_margin_sar, fixed_cost_sar | how the profit is built: units sold × margin per unit − fixed cost |
profit_sar | the payoff: profit of the alternative in this state, in SAR |
import numpy as np
import pandas as pd
BASE = "https://chebil.github.io/BusinessDecision/data/"
def load(name):
"""Read a course dataset from the website, or from a local copy of the repository."""
try:
return pd.read_csv(BASE + name)
except Exception: # offline, or working from a copy of the course repository
return pd.read_csv("../data/" + name)
data = load("qahwa_kiosk_decision.csv")
kiosk = data[data["case"] == "kiosk"]
kiosk1. The payoff table¶
A decision under uncertainty has three ingredients: the alternatives we choose from, the states of the world that may happen (here the festival’s footfall: High, Medium or Low), and a payoff for every pair. Profit is built from the planning team’s estimates: cups sold over the season × 10 SAR of margin per cup, minus the fixed cost of the site, the fit-out and the staff (520,000 SAR for the big kiosk, 200,000 SAR for the small one). A pivot turns the long table into the classic payoff table, in thousand SAR:
ALTS = ["Big", "Small", "No kiosk"]
STATES = ["High", "Medium", "Low"]
payoff_table = (kiosk.pivot(index="alternative", columns="state", values="profit_sar")
.loc[ALTS, STATES] / 1000) # thousand SAR
payoff_tableThe big kiosk earns 400 thousand SAR if footfall is high but loses 260 thousand if it is low: its fixed cost is high and must be covered by many cups. The small kiosk’s results are much less spread out, from −40 to 180. Not opening is worth 0 whatever happens. No alternative is best in every state, so the choice depends on how we treat uncertainty.
2. Deciding without probabilities¶
Three classic rules choose without asking how likely each state is.
Maximax (the optimist): take each alternative’s best payoff, choose the largest.
Maximin (the pessimist): take each alternative’s worst payoff, choose the largest.
Minimax regret: the regret of a choice in a state is what we lose compared with the best choice for that state. Take each alternative’s largest regret, and choose the smallest.
regret = payoff_table.max() - payoff_table # best payoff in each state (column) minus each payoff
print("Regret table (thousand SAR):")
print(regret, "\n")
criteria = pd.DataFrame({
"best payoff": payoff_table.max(axis=1),
"worst payoff": payoff_table.min(axis=1),
"largest regret": regret.max(axis=1),
})
criteriaRegret table (thousand SAR):
state High Medium Low
alternative
Big 0.0 0.0 260.0
Small 220.0 40.0 40.0
No kiosk 400.0 140.0 0.0
print("maximax chooses ", criteria["best payoff"].idxmax())
print("maximin chooses ", criteria["worst payoff"].idxmax())
print("minimax regret chooses", criteria["largest regret"].idxmin())maximax chooses Big
maximin chooses No kiosk
minimax regret chooses Small
Three rules, three different answers. The optimist opens the big kiosk, the pessimist opens nothing, and the regret-avoider opens the small kiosk (its largest regret, 220, is the smallest: 220 if footfall is high and it missed the big kiosk’s profit). Each rule encodes an attitude, and none of them uses what we know about how likely the states are. When the probabilities can be estimated, we should use them.
3. Expected monetary value¶
The team estimated the probabilities from the footfall of the festival’s two previous seasons and this season’s advance ticket sales: High 0.30, Medium 0.50, Low 0.20. The expected monetary value (EMV) of an alternative is its probability-weighted average payoff, .
prior = kiosk.groupby("state")["prior"].first().loc[STATES]
emv = payoff_table @ prior # one weighted sum per alternative
print(prior.to_dict())
emv.round(1){'High': 0.3, 'Medium': 0.5, 'Low': 0.2}
alternative
Big 138.0
Small 96.0
No kiosk 0.0
dtype: float64The big kiosk has the highest EMV, 138 thousand SAR, against 96 for the small one. EMV is the right criterion for a decision maker who faces many similar decisions and can absorb the ups and downs, because over many decisions the average is what remains. But this season will produce one outcome: 400, 140 or −260, never 138. We come back to that in section 8.
How sensitive is the choice? The probabilities are estimates. Suppose the chance of low footfall is not 0.20 but some , with High and Medium sharing the rest in the same 3 : 5 ratio. For which is the big kiosk still the best?
import matplotlib.pyplot as plt
def emv_at(p_low):
probs = pd.Series({"High": (1 - p_low) * 3 / 8, "Medium": (1 - p_low) * 5 / 8, "Low": p_low})
return payoff_table @ probs
grid = np.linspace(0, 0.8, 161)
curves = pd.DataFrame([emv_at(p) for p in grid], index=grid)
switch = grid[np.argmax(curves["Small"].values > curves["Big"].values)]
print(f"the small kiosk overtakes the big one when P(Low) passes about {switch:.2f}")
fig, ax = plt.subplots(figsize=(7, 3.4))
for alt, col in zip(ALTS, ["#D2691E", "#4C9BC9", "#888888"]):
ax.plot(grid, curves[alt], color=col, lw=2.5, label=alt)
ax.axvline(0.2, color="black", ls=":", lw=1)
ax.annotate("today's estimate 0.20", xy=(0.2, 205), xytext=(0.24, 210), fontsize=9)
ax.axvline(switch, color="black", ls="--", lw=1)
ax.annotate(f"switch at {switch:.2f}", xy=(switch, -150), xytext=(switch + 0.03, -150), fontsize=9)
ax.set_xlabel("probability of low footfall")
ax.set_ylabel("EMV (thousand SAR)")
ax.legend(loc="upper right")
plt.show()the small kiosk overtakes the big one when P(Low) passes about 0.33

The big kiosk stays the EMV choice as long as the probability of low footfall stays below about 0.33; above that the small kiosk wins. Our estimate, 0.20, is not far from that threshold, so the decision is only moderately robust: an analyst should tell the owner exactly this, not just “open the big kiosk”.
4. Decision trees¶
A decision tree draws the decision in the order things happen, from left to right:
a square is a decision: we choose one branch;
a circle is a chance node: the world chooses a branch, with the probabilities written on it;
each path ends in a payoff.
The tree is solved by folding back from right to left: a chance node is replaced by its expected value, and a decision node by its best branch. A tree is easy to write in Python as nested dictionaries, and folding back is a short recursive function:
# Three kinds of node. A tree is nested dictionaries built from them.
def payoff(value):
return {"kind": "payoff", "value": value}
def chance(branches):
"""branches: a list of (label, probability, child node)."""
return {"kind": "chance", "branches": branches}
def decision(options):
"""options: a dict {label of the alternative: child node}."""
return {"kind": "decision", "options": options}
def rollback(node):
"""Fold the tree back from its leaves: return the node's value and store the best option at each decision."""
if node["kind"] == "payoff":
return node["value"]
if node["kind"] == "chance": # a chance node is worth its expected value
return sum(p * rollback(child) for label, p, child in node["branches"])
values = {label: rollback(child) for label, child in node["options"].items()}
node["values"] = values
node["best"] = max(values, key=values.get) # a decision node is worth its best option
return values[node["best"]]def kiosk_choice(probs):
"""The kiosk decision, given probabilities for the three footfall states."""
return decision({
alt: chance([(s, probs[s], payoff(payoff_table.loc[alt, s])) for s in STATES]) if alt != "No kiosk" else payoff(0)
for alt in ALTS
})
tree = kiosk_choice(prior)
value = rollback(tree)
print("values of the options:", {k: round(float(v), 1) for k, v in tree["values"].items()})
print(f"best option: {tree['best']}, worth {value:.1f} thousand SAR")values of the options: {'Big': 138.0, 'Small': 96.0, 'No kiosk': 0.0}
best option: Big, worth 138.0 thousand SAR
def draw_choice(ax, node, x0=0.0, y0=0.5, title=None):
"""Draw a one-decision tree: a square, one circle per uncertain option, and the payoffs."""
opts = list(node["options"].items())
ys = [0.84, 0.5, 0.14][:len(opts)]
ax.plot(x0, y0, "s", ms=16, color="#4C9BC9")
for (label, child), y in zip(opts, ys):
best = label == node["best"]
col, lw = ("#D2691E", 2.8) if best else ("#999999", 1.4)
ax.plot([x0, x0 + 0.33], [y0, y], color=col, lw=lw)
ax.text(x0 + 0.30, y + (0.04 if y >= y0 else -0.08), label, ha="right", fontsize=9, color=col,
weight="bold" if best else None) # just before the branch's end, clear of the line
if child["kind"] == "payoff":
ax.text(x0 + 0.36, y, f"{child['value']:.0f}", va="center", fontsize=9)
continue
ax.plot(x0 + 0.33, y, "o", ms=13, color="#F2B36D")
ax.text(x0 + 0.33, y - 0.085, f"EMV {node['values'][label]:.0f}", ha="center", fontsize=8.5)
for k, (s, p, leaf) in enumerate(child["branches"]):
yl = y + (1 - k) * 0.105
ax.plot([x0 + 0.33, x0 + 0.62], [y, yl], color="#BBBBBB", lw=1)
ax.text(x0 + 0.40, yl + 0.012, f"{s} {p:.2f}", fontsize=7.5)
ax.text(x0 + 0.64, yl, f"{leaf['value']:.0f}", va="center", fontsize=8.5)
ax.text(x0 - 0.02, y0 + 0.07, f"{node['best']}: {node['values'][node['best']]:.0f}", ha="center", fontsize=9, weight="bold")
ax.set_xlim(-0.12, 0.78); ax.set_ylim(-0.02, 1.0); ax.axis("off")
if title:
ax.set_title(title, fontsize=10)
fig, ax = plt.subplots(figsize=(7, 4))
draw_choice(ax, tree, title="The kiosk decision, folded back (thousand SAR)")
plt.show()
The tree gives the same answer as the EMV table (big kiosk, 138), and for a single decision it adds nothing. Its strength is sequences: decide, observe something, then decide again. That is exactly the survey question.
5. The value of perfect information¶
Before pricing the survey, ask a simpler question: what would a perfect forecast of footfall be worth? With one, the owner would always choose the best alternative for the state that is coming: the big kiosk if footfall will be high or medium, no kiosk if it will be low. Before the forecast arrives we still do not know which state it will announce, so we weight those best payoffs by the probabilities:
ev_perfect = (payoff_table.max() * prior).sum() # best payoff in each state, weighted by its probability
evpi = ev_perfect - emv.max()
print(f"expected value with perfect information: {ev_perfect:.1f}")
print(f"best EMV without information: {emv.max():.1f}")
print(f"EVPI = {evpi:.1f} thousand SAR")expected value with perfect information: 190.0
best EMV without information: 138.0
EVPI = 52.0 thousand SAR
The expected value of perfect information (EVPI) is 52 thousand SAR. No survey, study or consultant can be worth more than that, because no real study is better than a perfect one. EVPI is a ceiling: the survey costs 25, under the ceiling, so it might be worth buying. To know, we need to model how good the survey actually is.
6. Updating with a survey: Bayes’ rule¶
The firm’s record on past venue studies shows how often its survey said “favourable” for each footfall level that then occurred: 90% of the time when footfall turned out high, 60% when medium, and 20% when low (column p_positive). These are likelihoods, . The owner needs the reverse: given what the survey says, how likely is each state? Bayes’ rule turns one into the other:
hit = kiosk.groupby("state")["p_positive"].first().loc[STATES] # P(favourable | state)
def posterior(prior, likelihood):
"""Bayes' rule: return P(result) and P(state | result)."""
joint = prior * likelihood # P(state and result)
p_result = joint.sum()
return p_result, joint / p_result
p_fav, post_fav = posterior(prior, hit)
p_unf, post_unf = posterior(prior, 1 - hit)
bayes = pd.DataFrame({"prior": prior, "P(favourable | state)": hit,
"after favourable": post_fav, "after unfavourable": post_unf}).round(3)
print(f"P(favourable) = {p_fav:.2f}, P(unfavourable) = {p_unf:.2f}")
bayesP(favourable) = 0.61, P(unfavourable) = 0.39
The survey will say “favourable” with probability 0.61. If it does, high footfall becomes more likely (from 0.30 to 0.443) and low footfall much less likely (from 0.20 to 0.066). If it says “unfavourable”, low footfall rises to 0.410. The survey moves the probabilities, but it is far from perfect: it says “favourable” for one low-footfall venue in five.
7. Is the survey worth 25,000 SAR?¶
Now the full tree: first decide whether to buy the survey; if we buy it, see its result, then choose the kiosk with the updated probabilities. The survey’s price is subtracted from every payoff on that branch.
SURVEY_COST = 25 # thousand SAR
def shift(node, amount):
"""The same subtree with every payoff changed by amount (to charge the survey's price)."""
if node["kind"] == "payoff":
return payoff(node["value"] + amount)
if node["kind"] == "chance":
return chance([(s, p, shift(c, amount)) for s, p, c in node["branches"]])
return decision({k: shift(c, amount) for k, c in node["options"].items()})
full = decision({
"No survey": kiosk_choice(prior),
"Survey": chance([
("favourable", p_fav, shift(kiosk_choice(post_fav), -SURVEY_COST)),
("unfavourable", p_unf, shift(kiosk_choice(post_unf), -SURVEY_COST)),
]),
})
rollback(full)
after_fav, after_unf = full["options"]["Survey"]["branches"][0][2], full["options"]["Survey"]["branches"][1][2]
print(f"No survey: {full['values']['No survey']:.1f} Survey (after paying 25): {full['values']['Survey']:.1f}")
print(f"best first move: {full['best']}")
print(f"if favourable: {after_fav['best']} ({after_fav['values'][after_fav['best']] + SURVEY_COST:.1f} before the survey's price)")
print(f"if unfavourable: {after_unf['best']} ({after_unf['values'][after_unf['best']] + SURVEY_COST:.1f} before the survey's price)")No survey: 138.0 Survey (after paying 25): 133.6
best first move: No survey
if favourable: Big (228.9 before the survey's price)
if unfavourable: Small (48.7 before the survey's price)
With the survey, the owner’s policy would be: big kiosk if favourable, small kiosk if unfavourable. That flexibility is the only reason the survey has any value: information is worth something only when it can change the decision. The expected value of sample information (EVSI) measures it, comparing the tree’s value with the survey (before its price) and without:
ev_with_survey = full["values"]["Survey"] + SURVEY_COST
evsi = ev_with_survey - emv.max()
print(f"EV with the survey, before its price: {ev_with_survey:.1f}")
print(f"EVSI = {evsi:.1f} price = {SURVEY_COST} EVPI = {evpi:.1f}")
print(f"efficiency of the survey: EVSI / EVPI = {evsi / evpi:.0%}")EV with the survey, before its price: 158.6
EVSI = 20.6 price = 25 EVPI = 52.0
efficiency of the survey: EVSI / EVPI = 40%
The survey is worth 20.6 thousand SAR to the owner, less than its 25 thousand price: do not buy it, open the big kiosk directly. The two benchmarks bracket the price the wrong way round: EVPI (52) said the survey could be worth buying, EVSI (20.6) says this survey is not. Its efficiency is only 40%, mainly because it too often says “favourable” for a venue that will be quiet, and a quiet venue is exactly where the big kiosk loses money. Note what the tree compares: 133.6 with the survey (after paying for it) against 138 without; the difference, 4.4, is the price minus the EVSI.
8. Risk attitude: when the EMV is not enough¶
The owner is not a large company running hundreds of kiosks. A loss of 260 thousand SAR in one bad season would wipe out the expansion budget for two years. Many people, rightly, would accept a lower average to avoid that. Utility puts a number on that attitude: a utility function gives the value of a payoff to this decision maker, and a risk-averse one maximises expected utility instead of the EMV.
A common choice is the exponential utility , with one parameter, the risk tolerance : the smaller , the more the decision maker fears losses. A quick way to estimate : it is roughly the largest amount for which you would accept a 50-50 gamble to win or lose . The owner says 300 thousand SAR.
The certainty equivalent (CE) of a risky alternative is the sure amount the decision maker values as much as the gamble: . The risk premium is , what they would give up to remove the risk.
def certainty_equivalent(values, probs, R):
"""CE of a gamble for exponential utility U(x) = 1 - exp(-x / R)."""
expected_utility = (probs * (1 - np.exp(-values / R))).sum()
return -R * np.log(1 - expected_utility)
R = 300
RISKY = ["Big", "Small"] # "No kiosk" is worth 0 for sure: its CE is 0
risk = pd.DataFrame({"EMV": emv[RISKY],
"CE (R = 300)": [certainty_equivalent(payoff_table.loc[a], prior, R) for a in RISKY]})
risk["risk premium"] = risk["EMV"] - risk["CE (R = 300)"]
risk.round(1)For this owner, the big kiosk is worth only 42.3 thousand SAR for sure, the small kiosk 85.7: the risk-averse choice is the small kiosk, the opposite of the EMV choice. The big kiosk’s risk premium (95.7) is two thirds of its EMV, because its one bad outcome is so bad. How risk-tolerant would the owner need to be for the big kiosk to win again?
from scipy.optimize import brentq
gap = lambda R: certainty_equivalent(payoff_table.loc["Big"], prior, R) - certainty_equivalent(payoff_table.loc["Small"], prior, R)
R_switch = brentq(gap, 100, 3000)
print(f"the big kiosk becomes the preferred choice once R is above about {R_switch:.0f} thousand SAR")
Rs = np.linspace(100, 1500, 141)
fig, ax = plt.subplots(figsize=(7, 3.4))
for alt, col in [("Big", "#D2691E"), ("Small", "#4C9BC9")]:
ax.plot(Rs, [certainty_equivalent(payoff_table.loc[alt], prior, r) for r in Rs], color=col, lw=2.5, label=f"{alt}: CE")
ax.axhline(emv[alt], color=col, ls=":", lw=1.2)
ax.text(1500, emv["Big"] + 6, "EMV 138", ha="right", fontsize=9, color="#D2691E")
ax.text(1500, emv["Small"] - 18, "EMV 96", ha="right", fontsize=9, color="#4C9BC9")
ax.axvline(R, color="black", ls=":", lw=1)
ax.text(R + 15, -60, "the owner\nR = 300", fontsize=9)
ax.axvline(R_switch, color="black", ls="--", lw=1)
ax.text(R_switch + 15, -60, f"switch\nR = {R_switch:.0f}", fontsize=9)
ax.set_xlabel("risk tolerance R (thousand SAR)")
ax.set_ylabel("certainty equivalent")
ax.set_ylim(top=165)
ax.legend(loc="lower right")
plt.show()the big kiosk becomes the preferred choice once R is above about 592 thousand SAR

As grows, each certainty equivalent rises towards its EMV: a decision maker with unlimited tolerance is risk-neutral and simply maximises the EMV. The owner would need a risk tolerance of about 592 thousand SAR, twice the stated 300, before the big kiosk became the better choice for them.
What to tell the owner. On expected value, the big kiosk is best (138 thousand SAR) as long as low footfall stays below about one chance in three, and the survey is not worth its price. But the big kiosk loses 260 thousand in a quiet season; for an owner who could not absorb that, the small kiosk (EMV 96, worst case −40) is the better choice. The analysis does not decide for the owner. It makes the trade-off explicit: about 42 thousand SAR of expected profit, the price of avoiding a 260-thousand-SAR loss.
Summary¶
| Idea | What it does | Kiosk result |
|---|---|---|
| Payoff table | alternatives × states of the world → payoff | Big: 400, 140, −260; Small: 180, 100, −40 |
| Maximax, maximin, minimax regret | choose without probabilities | Big, No kiosk, Small: three different answers |
| EMV | probability-weighted average payoff | Big 138, Small 96; Big stays best while P(Low) < 0.33 |
| Decision tree | decisions and chance events in time order, folded back | the same choice, and room for sequences |
| EVPI | the most any information can be worth | 52 |
| Bayes’ rule | turns a survey’s hit rates into updated probabilities | favourable: P(High) 0.30 → 0.443 |
| EVSI | what this survey is worth | 20.6 < 25: do not buy it |
| Utility, CE | decide as a risk-averse owner | R = 300: CE Big 42.3, Small 85.7 → Small |
Next week, Monte Carlo simulation replaces the three footfall states with whole probability distributions and simulates thousands of seasons, so the owner can see the full range of outcomes instead of three.