A New Safety Stock Formula - Part 4
This article explains a deviation metric to replace standard deviation in safety stock formulas. It is part 4 in a series where I present an experimental new safety stock formula. I start with the most commonly used safety stock formula, the King formula, and work towards a new formula. Although the King formula has some well-known and dramatic accuracy issues, it is still used pervasively because better options are not readily available. In this series I attempt to address each issue separately and combine them in a formula that any company can implement in Excel or other inexpensive software.
The series consists of the following parts:
Each individual contribution can be added independently of the other parts, and tests conducted suggest that each will already improve upon the original King formula. Readers are encouraged to experiment with their own data, and I would greatly appreciate any feedback from such experiments, either privately or as comments to these articles.
Introduction
A recurring assumption in the King formula and other known safety stock formulas is that demand and supply are normally distributed. In the previous article I demonstrated the dramatic impact on accuracy this assumption causes and introduced the concept of a one-sided deviation to replace the standard deviation in safety stock formulas. As I mentioned there, the right way to tackle this is very difficult to do with any level of accuracy. So we will not cover the right way, but instead in this article I will provide a few alternatives that will yield improved results with less complexity.
Option 1 - A tweak to the standard deviation formula
The formula for standard deviation is:
Apologies for the huge formulas, LinkedIn does not allow making it any smaller.
Standard deviation counts the value xi of every single occurrence i. For a one-sided deviation we would only want to count the occurrences that are equal or greater than the central tendency, be it mean, median, or mode (as explained in part 3). We ignore every occurrence less than the central value. But the occurrences that are equal to the central value we only count half. By doing so, the one-sided deviation is identical to the standard deviation when the distribution is symmetrical. The numerator does not change because we add half of zero, but the denominator does change.
We will introduce a function I that is 0 when xi < x, 1/2 when xi = x, and 1 when xi > x. The one-sided deviation formula is then:
If you were to calculate it over a subset of all occurrences, you would subtract 1 from the denominators in each of these formulas. With this minor change to the standard deviation we extend the use (including all cases that satisfied the original assumption of normality) to many commonly found skewed distributions.
However, not all tails of all distributions are adequately approximated by this approach. The example distribution from the previous article has a heavier tail than most. To get an accurate estimate of the tail around 97.7% cycle service the one-sided deviation needs to be 2.95 times greater than the standard deviation. Using the above formula the result is only 1.87 times greater. Better than the standard deviation, but not by a lot. The example was chosen for this very reason, to illustrate that the approach is not a silver bullet.
There is some degree of freedom as illustrated by the following graphic. It is the same as the one in part 3, with one more curve added.
Recall, the?horizontal?axis shows the?targeted?service level. The?vertical?axis shows the achieved?service level. In the ideal situation these would be the same, represented by the diagonal blue line of the real distribution. Note that the scale is 80% to 100% horizontal and 75% to 100% vertical to zoom in on the typical range of service that is targeted.?The extra purple curve which intersects the real distribution at about 90% cycle service, has a deviation that is a factor of 2.45 greater than the standard deviation. It is worse than 2.95 at the higher service ranges, but still reasonable, and better at lower service level ranges. Not far below this value it deteriorates rapidly to the standard deviation at all service level ranges. What this shows us, is that we do not need to be very precise in where we peg the service level to the real one, the results are not very sensitive up to a certain point. This leads us to another option to calculate an alternative deviation.
领英推荐
Option 2 - picking a high sample value
The cdf P describes the probability p that an occurrence x is less than or equal to a given value X, for some distribution. Formally: P(x ≤ X) = p. In our example if we want to determine the value at 97.7% cycle service we would have to find the X where P(x ≤ X) = 0.977. If we had 1000 historical values in a stationary series this would be easy. We sort them in ascending order and take the 977th value. Let's say the quantity of this 977th value is 316, then P(x ≤ 316) = 0.977, and at that sample size it should be reasonably close to the real value we are looking for.
In practice usually we do not have that many occurrences in our samples. If we are looking for the 97.7th percentile but we had 100 values we could pick either the 97th or 98th sorted value, and choose to either under-estimate or over-estimate by a small margin. If we had only 10 values in our sample, we pick the 9th or 10th, and accept a bigger error. Any samples smaller than that pose a real problem to our accuracy. It may be worth taking a weighted average of the values found just below and just above the desired percentile.
Note on closed form
If you have a fitted probability distribution, you simply calculate the value at the desired percentile and be done with it. In practice this is not feasible in most cases because forecasting algorithms pervasively assume a normal distribution, which will prevent getting a meaningful one-sided deviation value.
Translating the value to a deviation
In our example the 97.7th percentile equated to 2 standard deviations if we had used a normal distribution. If we wanted to calculate the one-sided deviation around the mode, which is 50 in the example, we subtract 50 from the found value at the percentile in the sample, say 316, and divide by 2: Sigma+ = (316-50)/2 = 133.
In MS Excel we would use the following formula: =NORM.INV(0.977, 0, 1), and the result is slightly less than 2, due to rounding. This is the denominator in the sigma+ formula.
If we wanted to find the deviation at 95% cycle service, we replace 0.977 with 0.95 in the Excel formula to find 1.645 as the denominator. The 95th percentile value found from the sample may be 248, then the deviation sigma+ becomes (248-50)/1.645 = 120.
If instead we wanted to find the one-sided deviation around the median (79 in the example) instead of the mode, the results would be (316-79)/2 = 118 for 97.7% service and (248-79)/1.645 = 103 for 95% service. In the next parts we'll cover where it makes sense to use the median and where to prefer the mode.
Non-Stationarity
If the historical time series has non-stationary behavior, such as trends, seasonality, or causal effects, simply taking the sample values at face value will generally lead to an over-estimation of the required stock. To apply these calculations to historical data it may be necessary to first de-trend, de-seasonalize, and/or de-causalize the historical data. Then find the right value and apply the process in reverse: trend, seasonalize, and/or causalize the value again. Realize that not just the average expected demand in a time range changes with these effects, the whole range of possible values does, including the upper percentile ranges where we are looking for service. For simplicity, you can apply the same factor for the service level percentile as you do for the average. For example, if the forecast in the upcoming lead time period is 20% greater than average demand due to seasonality, you would inflate the found quantity at the service level target percentile also with 20%. In the used example if the 97.7% one-sided deviation was in a time range with a 20% seasonal lift, and the sample distribution was based on de-seasonalized data, to determine the deviation we would use: (1+0.2)*(316-50)/2 = 160. Naturally, we made some simplifying assumptions here. Again, the goal is not to get perfect, but to get better than today.
If you are already doing this removal/application of effects to generate a forecast, it should not be a very large amount of extra effort for a handsome increase in service level. Most commercial forecasting systems will give you baseline demand and baseline forecast allowing you to use those for the calculations. You can use the historical fitted error residuals to determine the percentile of the distribution. Note that even though the forecasting algorithm may assume the errors are normally distributed around zero, you do not want to do that. Instead your median or mode will likely be some negative value, since the mean has already been subtracted to find the residuals.
If you are not already doing this, your existing safety stock calculation will be inflated, but it will be compensated by the under-estimation of the standard deviation. In such case, take great care if you replace the standard deviation with a one-sided deviation, since you may overshoot both your service target and the required inventory to provide it. You will need to determine if the effects of not correcting for non-stationary behavior are negligible or not. This is something that is wise to do any way, regardless of the current topic.
For supply lead time variability, significant non-stationarity is the exception, not the rule. Most companies will only need to worry about this for demand. There are industries where lead times are very seasonal though. If yours is, you will already be aware, and you may want to make a lead time forecast to increase the accuracy of your safety stock. If you do not know if your supply lead times are seasonal, they most likely are not and you can safely use the raw lead time data in the above explained calculations.
Conclusion
In this article I have provided two feasible options to calculate a one-sided deviation. The first is the most elegant, but it may not be very good when tails of the demand or supply distributions are heavier than normal. Thankfully, that is not very common, and the result will still be better than using the standard deviation. You may want to test your historical data to ascertain if heavy tails exist and how severe they may be. Remember to always determine this at the exact granularity where you are calculating safety stock: item/ship-from/lead-time. Alternatively, you could just try it and test if the improvement is sufficient to bridge the service level gap. If it is not, you may want to switch to option 2 instead. In this regard, beware that in many supply chains lots of expediting and transfers occur that will improve service levels. You need to subtract these cases from the measured service to find the service provided from inventory. It is this reduced service that we want to compare against the targets set in the safety stock calculation. If we can get the safety stock to achieve the targets, expediting and transfers should reduce dramatically.
You can find an Excel file with sample data and calculations of the two options with various lead times here. Note that this is a macro-enabled format. If you have macros enabled in Excel it can be used to run a simple Monte Carlo simulation. If you choose to disable macros, everything else will still work, only simulation will be disabled.
Up to this point we have covered mostly theory. In the next part we will cover the best way to apply it to demand.
Find all my articles by category here. Also listing outstanding articles by other authors.
...using your own words: ...you "still owe" us "a few more parts".... you indeed do! :)
SAP Senior business analyst | Logistics, PLM consultant | SAP Mentor
2 年Hi Stefan, Thanks for your valuable series about Safety stock. Unfortunately, the Excel file link is not working, could you provide another link? ??
when "the next part" :) come on !! Cheers mate Andrea
Solution adoption, NPS, training
3 年Hi Stefan de Kok really find your articles very useful. Inventory is such an interested topic, I am looking forward to the rest of your part 4 to 9.. Do you have a time in mind when you would be able to share with us? Thanks
Continuous Improvement Engineering Team Lead at ITW Hartness
4 年Great article!!!! not sure if this is a stupid question... but should we drop Demand outliers when calculating Safety stock?