Build a what-if model
Write a decision as a small model of what you control, what you don't, and what you care about, then move it to see what changes.
What runs in CodeSplash
- Monte Carlo simulation of a scenario model Verified in Python and R
You will be able to
- Sort a problem into decisions, uncertain inputs, formulas and KPIs
- Compute a model's result at its base values
- Use what-if sliders, and say what they can't show
How much should you order?
ReadYou sell a seasonal product. You order once, before you know the demand. Order too little and you lose sales. Order too much and you're left with stock.
Four parts make a model of this:
- Decision: what you control. The order size.
- Inputs: what you don't control. Demand and price.
- Formulas: how they connect. Sales are the smaller of demand and order.
- KPI: what you care about. Profit.
Sort them
CheckpointCheck yourself
You're planning a marketing budget. Which of these is an uncertain input?
Show the answer
Answer: b
You choose the spend, so that's a decision. Customer response is outside your control, and uncertain, so it's an input.
Check yourself
Which makes the better KPI for a stocking model?
Show the answer
Answer: a
A KPI is an outcome the model computes. Order size is a decision, and demand is an input.
Run the numbers
CheckpointSay demand is 1,000 and you order 1,100, at a unit cost of 6. Price follows a triangular distribution from 9 to 12, most likely 10, whose mean is .
Check yourself
What's the profit at those values? Round to the nearest whole number.
Show the answer
Answer: 3733.33333333333
Sales = min(1,000, 1,100) = 1,000. Profit = 10.33 × 1,000 − 6 × 1,100 = 10,333 − 6,600 = 3,733.
Move the decision
ExploreHere's a similar stocking problem with its own prices. Move your order, up and down from average demand.
DExplorable · The newsvendor
When demand is uncertain, should you order more or less than you expect to sell?
With these margins, should you order more or less than average demand?
- Your order: 1000
Commit your prediction above to see the result
Make your prediction to see the result.
Does profit fall at the same rate on both sides? It usually doesn't. That's why the best order is rarely the average demand: it depends on how a lost sale compares with a leftover unit.
What a slider can't tell you
PredictPredict first
Your slider says that at the average demand and price, an order of 1,100 makes about 3,733. Is that what you should expect to earn?
Reveal
Not necessarily. Sales can't exceed what you stocked, so high demand can't make up fully for low demand. The next lessons show that the average outcome falls below the outcome at average inputs.
Build one
In the appIn Studios, open Scenarios & optimization and choose Inventory (newsvendor). It needs no dataset. The Model step lists the inputs, decisions, formulas and KPIs. Each input can take a three-point estimate, or be fitted to a dataset column. The What-if step has the sliders.
This tour moves a decision, saves a scenario and simulates it.
Recap
Recap- A model separates what you control from what you don't, and ties them to what you care about.
- What-if shows how the result moves at particular values.
- Results at average inputs aren't average results, which is what simulation is for.