Planning for More Than One Possible Outcome
A delivery might contain different numbers of damaged sensors. Keep the possible outcomes and their probabilities together before deciding how many replacements to hold.
13 sections · 4 questions · 2 coding challenges
The arrow keys move between sections too.
From Games of Chance to Decisions Under Uncertainty
BOTIE
Before updating an unknown chance, we need a way to describe a known set of possibilities. Our damaged-sensor distribution is an invented discrete example, chosen so every outcome and probability can be inspected.
Sources for this history
How Many Spare Sensors Should Botie Keep?
Botie receives boxes of sensors. Some arrive undamaged, while others need replacements. Ordering for just the most common outcome can leave him unprepared for the less common ones.
We need two pieces of information: what could happen and how likely each possibility is. A distribution keeps these together. We can then calculate an average requirement or compare the consequences of different stocking decisions.
The damage counts and their probabilities form an invented distribution.
Step 1 of 3
List the possibilities
An outcome is a number of damaged sensors, not the probability of that number.
Damaged sensors
- Possible count 10
- Possible count 21
- Possible count 32
Step 2 of 3
Attach probabilities
These mutually exclusive possibilities cover the whole example.
| Possible delivery | Probabilities |
|---|---|
| 0 damaged | 0.5 |
| 1 damaged | 0.3 |
| 2 damaged | 0.2 |
0 damaged
- Probabilities
- 0.5
1 damaged
- Probabilities
- 0.3
2 damaged
- Probabilities
- 0.2
Step 3 of 3
Average over possibilities
Weight each possible count by how often it would occur in repeated deliveries.
Expected damage = (0 × 0.5) + (1 × 0.3) + (2 × 0.2) = 0.7 Most likely individual count: 0 (probability 0.5)
Expectation weights outcomes by how often they are expected to occur
Weighting preserves how frequently each outcome is expected to contribute.
How should Botie plan for several possible damage counts?
No single outcome describes every delivery. Change the probability shares, keeping their total at one, and compare the weighted count with the individual outcomes.
BOTIE
Expected damage count
0.7
Follow the operations
1. Possible counts
- 00
- 11
- 22
2. Probabilities
- 00.5
- 10.3
- 20.2
3. Check a probability distribution
- 00.5
- 10.3
- 20.2
4. Dot product
0.7
5. Result
0.7
Probabilities must sum to one. This average is not the most likely outcome.
1. Separate Outcomes From Their Probabilities
Let's make a table with one position for each possible count of damaged sensors. Beside that count, put its probability. Every probability must be nonnegative, and together they must add to one, because our listed outcomes exhaust the possibilities.
A count takes discrete values. Temperature is different: a continuous model describes it with a density. To find the probability of a temperature range, we take the area under that density over the range. The density's height at a single temperature is not a probability.
A distribution is a description of uncertainty under a model, not a guarantee about the next delivery.
2. Calculate an Expectation
Imagine receiving many deliveries under the same conditions. Outcomes with larger probabilities should contribute more to the average. Multiply each count by its probability and add the contributions.
The result need not be an outcome that one delivery can actually have. We cannot receive a fraction of a broken sensor, but we can have a fractional average across deliveries.
E[damage] = 0 × 0.5 + 1 × 0.3 + 2 × 0.2
E[damage] = 0.7Expectation answers an average question. It does not replace the whole distribution.
3. Put the Cost of a Decision in the Table
Suppose each missing spare causes a delay. For a proposed stock level, calculate the shortage in each outcome, keeping only positive shortages. Weight those shortages by their probabilities.
We can repeat this calculation for several stock levels. If holding spares also costs money, include that cost before comparing decisions. The cheapest choice depends on both the distribution and the consequences.
Stock one spare: shortages = [0, 0, 1]
Expected shortage = 0 × 0.5 + 0 × 0.3 + 1 × 0.2 = 0.2The most likely outcome does not necessarily produce the lowest expected cost.
Keep the probability beside the damage count
A delivery can damage zero, one or two items. Multiply each count by its probability before adding; neither the most likely outcome nor an unweighted average answers this question.
import numpy as np
counts = np.array([0., 1., 2.])
probabilities = np.array([0.25, 0.5, 0.25])
contributions = counts * probabilities
print(contributions.tolist())
print(float(contributions.sum()))[0.0, 0.5, 0.5]
1.0One is the expected count under this distribution. Individual deliveries can still have any of the three listed outcomes.
4. Check Whether the Table Still Describes Deliveries
The probabilities might have come from historical frequencies or a fitted model. A new supplier or a change in packaging can make those values inappropriate. Compare predictions with later deliveries and retain rare outcomes when they matter.
Expected cost is one decision rule. A service requirement might instead limit the chance of any shortage. State which objective is being used before choosing a stock level.
Botie’s workshop computes an expectation. The choice of stocking objective remains a separate decision.
5. An Expected Count Need Not Be a Possible Count
A shipment can contain zero, one or two damaged sensors. Its expected damage count can lie between those integers because it averages across possible shipments, weighted by their probabilities. It is not a claim that a particular shipment contains a fraction of a sensor.
If Botie must order whole replacement units, rounding the expectation is one possible rule. Whether it is useful depends on the consequences of too many or too few replacements. A prediction summary and an action are different objects.
6. Average the Consequences of Each Stock Decision
Suppose an unused replacement costs one unit, while a shortage costs five per missing replacement. For each stock choice, calculate the cost under every damage outcome and then take its probability-weighted average.
This is the same expectation operation, now applied to cost instead of damage count. It connects a probability distribution to a decision without pretending the most likely outcome is the only one that matters.
Choose among three replacement stocks
The invented damage distribution is shared by every stock choice.
import numpy as np
damage = np.array([0,1,2])
probability = np.array([.5,.3,.2])
for stock in [0,1,2]:
unused = np.maximum(stock-damage, 0)
shortage = np.maximum(damage-stock, 0)
print(stock, round(float(probability@(unused+5*shortage)), 2))0 3.5
1 1.5
2 1.3Two replacements minimise expected cost under these probabilities and costs, even though zero damaged sensors is the most likely outcome.
7. Keep Uncertainty in the Probabilities Visible
The distribution may itself be estimated from a small or changing collection of shipments. A precisely computed expectation can therefore depend on uncertain inputs.
Repeat the decision calculation under plausible alternative damage rates and shortage costs. If the preferred stock changes easily, the decision needs more evidence or an explicit tolerance for risk. Arithmetic precision does not remove uncertainty about the model.
Check yourself
Questions on Parts 1 to 7
Question 1 of 4
Which count is most likely?
Use the information below.
Counts [0,1,2], probabilities [0.5,0.3,0.2].Try it with Botie
Build with Botie
Write and run Python