liveBook · Manning

Expected utility

As explained in Grokking Bayes

Expected utility is the probability-weighted average utility of an action across possible outcomes.

A likely outcome is not always the best reason to act. Launching a website design might usually help, yet a small chance of an expensive failure could change the decision. Expected utility combines two questions: How likely is each outcome, and how valuable would it be? section 12.2 section 11.10

For each action, multiply every possible outcome’s utility by its probability, then add the results. This probability-weighted average is the action’s expected utility. Bayesian decision theory chooses the action with the highest expected utility—not necessarily the action with the most likely favorable outcome. section 12.2

Should the new design launch?

Suppose launching yields a utility of 100,000 with probability 0.97 and a utility of −20,000 with probability 0.03. Its expected utility is 0.97 × 100,000 + 0.03 × (−20,000) = 96,400. Not launching yields 0, so launching wins under these utilities. If the loss were much larger, the preferred action could reverse even though success remained likely. section 12.2 section 11.10

Possible outcomes need not fit into a few categories. If an unknown conversion rate can take a continuous range of values, define utility for each rate and average it against the rate’s probability distribution. When that integral is difficult, draw many rates, calculate the utility of launching at each one, and average those utilities. In one such setup, the sample-based estimate is about $107,496 for launching versus $100,000 for not launching. section 12.5

np.random.seed(0)
r_samples = np.random.beta(
    64, 438,      #A
    size=100_000  #B
)
 
utility_samples = utility_launch(r_samples)  #C
expected_utility = utility_samples.mean()    #D

The NumPy listing draws 100,000 possible conversion rates, turns them into utility samples, and averages those samples to approximate expected utility. section 12.5

For a sequence of decisions, immediate expected utility may not tell the whole story. Trying a policy can reveal its payoff before deciding whether to try another. Work backward through the possible outcomes: compare later actions at each decision point, then use those choices to evaluate the first action. This captures the value of adapting, though traversing every branch becomes computationally costly over longer sequences. section 12.7 section 12.8 section 12.10

How Grokking Bayes covers it

How deep it goes
Defines and calculates discrete expected utility, extends it to continuous outcomes and sampling, then applies it to sequential decisions.
Examples
Uses website-launch payoffs, sampled conversion rates, and competing policies to show how probabilities, costs, and later choices affect decisions.
What it assumes
Builds on beliefs about outcomes and preferences over them, while introducing the probability-weighted decision rule with a worked example.
What you can do after
Apply it via probability-weighted sums or NumPy sampling to compare actions, and evaluate sequential choices by working backward through outcomes.
How it connects
Connects Bayesian decision theory and utility functions with posterior predictions, Monte Carlo sampling, and sequential decision-making.

Also explained in

Compare how 3 books explain expected utility →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Bayes. The section links point to the parts of the book it draws on.