7. Beyond Normality
Normal demand is a useful starting point, but it can be a poor description of some inventory items. Demand is often nonnegative and right-skewed: most periods are ordinary, with occasional unusually large orders. A Normal model is symmetric and assigns some probability to negative demand.
This chapter introduces the gamma distribution as one practical alternative. We will fit its parameters from demand summaries, account for a known minimum-demand offset, aggregate independent periods, and connect the distribution's upper tail to inventory targets and expected shortages. These are model-building tools, not an automatic rule that gamma is always better.
Diagnose the shape before choosing a model
Consider this synthetic monthly sales sample for one item:
| Month | Units |
|---|---|
| Jan | 68 |
| Feb | 73 |
| Mar | 75 |
| Apr | 76 |
| May | 78 |
| Jun | 79 |
| Jul | 80 |
| Aug | 81 |
| Sep | 82 |
| Oct | 84 |
| Nov | 92 |
| Dec | 112 |
The sample mean is about 81.7 units and the median is 79.5; the large December value pulls the mean upward. A fitted Normal curve may understate the chance of a large positive demand and may assign probability below zero. This does not establish that gamma is the correct model; it tells us to inspect the data, business calendar, and candidate distributions.
For observations , the population-moment skewness is:
Positive skew indicates a longer right tail, zero skew indicates symmetry in the third moment, and negative skew indicates a longer left tail. Different libraries use different sample corrections; state which convention is used when comparing values. Skewness alone does not describe the entire distribution.
Why inspect normality?
Two common mismatches matter for inventory:
- Support: an ordinary Normal distribution permits negative values. Clipping simulated values at zero changes the distribution and its mean; it is not a neutral implementation detail.
- Tail shape: Normal demand is symmetric around its mean. A right-skewed item can have more unusually high demand than a Normal model predicts, which matters when setting a high service target.
Returns should usually be modeled as a separate flow unless the business can truly use a return to satisfy a future customer demand. Do not casually treat returns as negative demand.
Fit a gamma distribution by moments
Use the shape-scale parameterization , where is the shape and is the scale. Its moments are:
Matching a positive mean and standard deviation gives:
Unlike the ordinary Normal distribution, gamma demand is supported on nonnegative values. Larger variation relative to the mean yields smaller and a more pronounced right tail. Be explicit about the software convention: some libraries use scale , while others use a rate .
The explorer shows the gamma density on its nonnegative support and reports a moment-matched Normal model's probability below zero. It is a visual comparison of support and shape, not a goodness-of-fit test.
A known minimum or baseline demand
If demand never falls below a credible operational baseline , model:
Fit the gamma component to the excess-demand mean and the original standard deviation :
This requires and . The floor should have a business or data-generating reason. Choosing the observed sample minimum automatically can overfit a small sample; validate the offset on new periods and compare tail behavior.
Aggregate demand over a policy risk period
Let period demands be independent and identically distributed gamma variables with the same scale . The sum of periods is also gamma:
For a demand floor per period:
For continuous review, use ; for periodic review, use . The risk-period safety stock for cycle service target is the gamma quantile minus the expected demand:
Here is the reorder point or order-up-to level , depending on the policy. In general this quantile requires a numerical library or table. SciPy's scipy.stats.gamma.ppf(alpha, a=shape, loc=offset, scale=scale) uses shape, location, and scale in that order. The lesson's Python exercises below avoid relying on SciPy by using precomputed CDF inputs where appropriate.
The exact sum result requires independent gamma variables with a common scale. If the period distributions have different scales, are correlated, or have changing parameters, the sum is not generally gamma; moment-matching another gamma is an approximation that should be validated.
Worked risk-period target with an offset
Suppose weekly demand has mean 800 units, standard deviation 200, and a justified floor of 400. The gamma component has excess mean , shape , and scale . For a five-week protection period, its shape is , its scale remains 100, and the offset is units.
If a numerical gamma quantile calculation gives the 95th percentile of as 2,787.92, the total inventory threshold is units. Expected five-week demand is , so the implied safety stock is about 788 units. The quantile here is illustrative; calculate it with a trusted distribution implementation and validate the chosen demand model on observed data.
From cycle service to expected shortage
Cycle service asks whether demand exceeds the inventory threshold at all. Fill rate asks what fraction of units are supplied immediately. For risk-period demand and inventory threshold , expected units short are:
For with , the gamma loss expression is:
For an offset gamma with risk-period floor , shift the inventory threshold to and evaluate the loss of the gamma component. If , every nonnegative gamma-component demand exceeds that shifted threshold, so expected shortage is ; for , use . This keeps offset handling explicit rather than applying a zero-location formula to the unshifted threshold.
A simple long-run fill-rate approximation for periodic review is:
The denominator is expected demand per replenishment cycle. For continuous review with fixed order quantity, the cycle-demand denominator is . This approximation and the loss expression rely on a specified shortage model; backorders, lost sales, and timing details can change the operational fill rate. Cycle service and fill rate are related but are not interchangeable.
Select a model carefully
Use diagnostics to decide what to investigate, not to declare a winner automatically.
Compare skewness as a first screen
A Normal distribution has theoretical skewness 0. A moment-matched gamma has skewness ; an offset gamma has . As a rough screen, compare across candidates. If observed skewness is much closer to one candidate, that is a useful signal for further testing. It does not prove that the candidate matches the actual tail or service-level quantiles.
Compare empirical and fitted distributions
A histogram can reveal asymmetry and outliers. If comparing candidates with a histogram, use the same bin edges and range. Convert each candidate's CDF into probability mass per bin, , and compare like with like. Density heights have units of inverse demand and depend on bin width; normalizing histogram heights by their sum is not generally a probability-density normalization unless the bin width is also accounted for.
For empirical bin proportions and model bin probabilities , one possible summary is:
An RMSE over bin probabilities is one summary, not a universal goodness-of-fit test. It weights all bins equally unless designed otherwise and may prioritize the center over the high-demand tail that drives shortages. For inventory decisions, inspect upper quantiles, exceedance counts, and service performance on held-out periods. A more advanced fit that fails out-of-sample checks is not an improvement.
Practice: fit, aggregate, and evaluate
Concept check
Gamma demand and model fit
1 / 5For a moment-matched Gamma(k, theta) with mean mu and standard deviation sigma, which parameter formulas use the shape-scale convention?
Pick an answer to see if you are right.
Rank the distribution-selection workflow
Put these steps in dependency order. Do not pick a model before checking its support and the data used to fit it.
Select and validate a demand model
1 / 1Choose a practical candidate distribution for an inventory item.
OrderDrag the handle to rearrange — top should be first.
- 1Document the chosen model, assumptions, and conditions that should trigger a refit.
- 2Estimate mean, standard deviation, skewness, and candidate parameters from training data.
- 3Check quantiles and service performance on held-out periods under the intended inventory policy.
- 4Compare candidate distributions using common bins or a suitable fit diagnostic, paying attention to the upper tail.
- 5Inspect the demand definition, time bucket, returns, zeros, and any credible minimum.
Drag items into the correct order (or use ↑↓), then check.
Python practice: measure sample skewness
Use population moments for this exercise so the result matches the chapter's formula. The first sample has a right-tail outlier; the second is symmetric.
| Sample | Observations |
|---|---|
| A | 1, 1, 1, 1, 5 |
| B | 1, 2, 3, 4, 5 |
Implement population_skewness(values). Return the standardized third central moment; raise ValueError if the data have zero variance.
Python practice: fit gamma parameters
The table contains summary statistics for synthetic demand streams. minimum is an externally justified operating floor, not a value to blindly set to the smallest observation in every sample. Use the population-moment convention stated above.
| Stream | Mean | SD | Minimum floor |
|---|---|---|---|
| A | 100 | 25 | 0 |
| B | 100 | 25 | 40 |
| C | 80 | 20 | 30 |
Implement fit_gamma(mean, sd, minimum). Return (offset, shape, scale, theoretical_skew), without rounding inside the function.
Python practice: aggregate a floored demand model
For independent, identical periods, gamma shapes add, the common scale stays fixed, and a per-period floor adds once per period. Use this table to check the aggregation.
| Case | Per-period mean | SD | Floor | Periods |
|---|---|---|---|---|
| A | 100 | 25 | 40 | 5 |
| B | 80 | 20 | 30 | 4 |
Implement aggregate_gamma(mean, sd, minimum, periods). Return (risk_mean, risk_sd, risk_offset, shape, scale).
Python practice: expected units short
For and inventory , expected shortage is:
Gamma CDF values are supplied in this table so the code exercise can focus on implementing the loss identity without requiring SciPy.
| Shape | Scale | Inventory | ||
|---|---|---|---|---|
| 2 | 10 | 20 | 0.593994 | 0.323324 |
| 2 | 10 | 10 | 0.264241 | 0.080302 |
Implement gamma_loss(shape, scale, inventory, cdf_k, cdf_k_plus_one) and return expected units short. These are model calculations, not a substitute for checking whether the fitted tail is realistic.
Takeaways
- Normality is convenient, not guaranteed; support and upper-tail fit matter to inventory decisions.
- For moment-matched , , , and skewness is .
- An offset gamma requires a defensible floor and ; fitting the sample minimum blindly can overfit.
- Independent same-scale gamma periods aggregate exactly by adding shapes; different scales or correlated periods need another model or an explicit approximation.
- Quantiles and expected-shortage formulas connect the chosen distribution to cycle service and fill rate, but model validation should focus on held-out upper-tail behavior.
Previous: Inventory Policy Simulation Lab.
Next: Multi-Echelon Inventory Optimization — coordinate safety stock across connected locations.