Turn results into decisionsLesson 49 of 76 · 7 min
Define what a bad outcome costs
Translate an objective into a loss calculation with interpretable units.
A simulation produces possible outcomes; a decision also needs an objective. A loss function converts an outcome and action into a consequence measured on a stated scale. It makes trade-offs explicit rather than leaving the choice to whichever summary looks favourable.
For a shop’s one-period stocking decision, shortage and leftover stock have different penalties. The same demand outcome can give a different loss under each stock choice. Those penalties express assumptions about consequences and priorities.
Expected loss averages over the modelled demand distribution. It is not necessarily the right objective for every decision: hard service constraints, risk aversion or consequences not captured in money may matter. Keep the probability model and the preference model separately reviewable.
- Unmet demand
- Unused stock
- Authored loss
Can changing a shortage penalty change the preferred stock level without changing demand?
Write a prediction (optional)
Seeded teaching simulation
Select Run Python below with the code unchanged.
A saved draft is open. To run the published example, open Tools and select Restore example. Recover draft brings your code back.
Execution error
Technical error details
Your result
Published example output
This result comes from the original Python. Your runs appear above. Build environment ↗
stock expected_loss P_shortage
20 54.723 0.814
25 23.992 0.453
30 15.297 0.139
35 20.591 0.022
Read the first result
A preference change can change the decision while every demand draw stays fixed. That is not a contradiction in the simulation.
Try an edit
Replace loss = 10*shortage + 2*leftover with loss = 3*shortage + 2*leftover. Select Run Python again. Which stock has the smallest expected_loss now? Check whether P_shortage changes when only the penalty changes.
Scope. The illustrative loss omits reputational effects, substitution and multi-period customer behaviour.
Try a fresh case
What does a penalty of £10 per unmet unit represent?
Need a hint?
Hint 1
Separate how often something happens from how much it matters.
Hint 2
Name the unit of the loss.