Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a task that is specific to inventory management that is currently driving me crazy. To summarize the problem: We regularly must monitor inventory settings to ensure that they represent true demand, to ensure that we are not overstocking nor understocking. The standard procedure is to schedule reviews, where high volume items get reviewed monthly, and low volume items quarterly. But the vast majority of SKUs don't get adjusted; less than 9% are adjusted after each review...meaning that 91% of SKUs do not have a significant change in their demand patterns to warrant any change in their inventory parameters. I'm trying to design a filter so that instead of reviewing every SKU, I only review the SKUs where demand patterns have likely changed from their previously implied demand.

To give background into the domain of inventory management:

1) Inventory SKUs have settings that manage their stock levels given a specified depletion rate and variability. There are practical parameters (eg. lead times) as well as calculated parameters (eg. avg daily demand), and often heuristic parameters (eg. targeted in stock rate).

2) Generally speaking, if I know all of the currently used parameters (or even n-1), I know the implied demand distribution that results in those parameters. For example, if I have a safety stock of 96 units, avg daily demand of 10, lead time of 5 days, and a target in-stock rate of 98%, and demand is normally distributed, then I know that the implied demand can be represented by a normal distribution with mean of 10 and standard deviation of 10.

I'm trying to find a method that can help me assign probabilities that a sample of demand came from an implied demand distribution with explicit parameters. Is there a way to calculate this probability? It sounds like a conditional probability problem, but I'm not sure how to construct a calculation to determine conditional probabilities using parameterized distributions.

To phrase this question as an example: If my last 10 days of demand are c(6,7,7,5,7,8,9,4,4,9), what is the probability that this sample came from a normally distributed population with mean of 5 and stdev of 3?

share|improve this question

migrated from Feb 20 '12 at 23:52

This question came from our site for professional and enthusiast programmers.

My guess is that you might want to use a Poisson distribution instead of a normal distribution because all of your data are counts. Then maybe try comparing your data with the expected values arising from a Poisson distribution with a mean of 5 using a Pearson's chi-square test. Unfortunately, all of my books I could use to double-check all of that are in the mail. – Mark Miller Feb 20 '12 at 23:49
We have three different distributions that we use, depending on product characteristics as well as fit, and include Gamma and Poisson distributions. The example given was just an example...I have over 12,000 SKUs that I would be processing as part of a batch process. The framework of the solution needs to be independent of the type of the distribution. I need to be able to take any sample, and determine the probability that it could have come from a specified distribution with specified parameters. – dannytoone Feb 21 '12 at 1:32
up vote 4 down vote accepted

That's a familiar problem from a previous life!

First, you're not going to be able to do exactly what you want, which is to come up with a probability that the observations could have come from a specified distribution etc. This is because you don't have a well-specified alternative distribution, one which the data comes from if all is not well. There are too many ways things could go wrong to come up with such a distribution easily, but without it, you have nothing to use to help you say something like "this collection of observations is more likely to have come from the inventory error demand distribution than from the regular demand distribution."

Having said that, though, you can still calculate $p(\text{new data} | \text{estimated parameters})$ and use that, along with the monetary value of the nominal on-hand inventory, to develop a ranking system for cycle counting the SKUs. There will undoubtedly be some trial-and-error involved, as low probabilities can be due to errors in the inventory records or misspecification of the probability distributions (or chance), and you want to count the former cases but not the latter cases.

In R, such a calculation, for your example, could be:

NewData <- c(6,7,7,5,7,8,9,4,4,9)
EstMean <- 5
EstSD <- 3
exp(sum(dnorm(NewData, EstMean, EstSD, log=TRUE)))

Having written that, I would highly recommend using the negative binomial distribution in preference to the Poisson for mean demands < 10 or 15 or so (and something continuous for higher demand levels.) In a long life of inventory control, I have only seen a situation where demands were well-modeled by a Poisson distribution once. The Gamma, too, has problems, since zero demands are not possible if demands are truly distributed Gamma, but stockouts do occur... in fact, I've found zero-inflated negative binomial distributions tend to fit a wide range of SKUs better than the standard form, and of course with the Gamma and (truncated) Normal also.

share|improve this answer
I have several questions, so I think I'll put them in separate comments. The first question is what is the purpose of the exp(sum(log(p-vector))? How should I interpret the result? – dannytoone Feb 21 '12 at 17:53
Second question: If I use a gamma (I use the mme fitting method with the fitdist function in fitdistrplus package, which appears to work well) fitting for a demand distribution, and there are zero values (for a day that did not have any demand), how will that affect how well demand can be modeled using that distribution? – dannytoone Feb 21 '12 at 17:56
Third question: how do stockouts play into this? In my specific domain, we have several products where demand may be zero for any given day, but we typically don't lose that demand due to stockouts because the order is typically not cancelled. – dannytoone Feb 21 '12 at 17:58
Last question: I have read the theoretical application of the negative binomial distribution, but I don't really see how it translates to demand distributions for inventory management. Is there a reason for choosing the zero-inflated negative binomial? – dannytoone Feb 21 '12 at 18:01
1) This is the same as taking the product of the p-vector; I just do it that way out of habit. The result is the joint probability (or density, if continuous distn's used) of the input data given the parameter estimates. 2) Zero demand + a gamma distribution = fail. Something must be done about those zeroes or about the gamma distribution. 3) In that case, stockouts are irrelevant. The greater point was that even moderate to high demand items can have zero demand days; "stockouts" was just a mechanism by which that can happen. Zero demand days don't work w/ the gamma dist'n. – jbowman Feb 21 '12 at 18:59

Look at the ks.test function for one option of comparing data to a given continuous distribution (with predefined parameters). Look at the vcd package for tools to examine discrete distributions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.