# Maximize the profit of a product given a Gamma distribution

I'm having trouble translating this problem into a workable form:

A bakery sells rolls in units of a dozen. The demand X (in 1000 units) for rolls has a gamma distribution with parameters $\alpha=3,\theta=.5$, where $\theta$ is in units of days per 1000 units of rolls.

At this point I am stuck as I am not sure what is what in the distribution. The remainder of the problem is as follows:

It costs \$2 to make a unit of rolls that sells for \$5 on the first day when the rolls are fresh. Any leftover units are sold for \$1 on the second day. How many units should be made to maximize the expected value of the profit? • See wikipedia's entry on the Gamma distribution. It looks to me like you are dealing with the second parameterization there (the one in the right column at the right hand side), that is, shape-rate, not shape-scale. – Glen_b Dec 8 '14 at 4:56 • A critical point that needs clarifying: For how long after the first day can rolls be sold before being destroyed? Warning: even if they can be sold for just one more day, the problem becomes dynamic (because the possibility of inventories arises, that "eats up" future demand). Redeeming simplification: "demand" refers to "demand for fresh rolls", while the "left-overs" are sold at the end of the day they are produced, at the low price (i.e we assume some extra demand that arises only for the left-overs due to the low price). So no inventories, and it becomes easy then. So? – Alecos Papadopoulos Dec 8 '14 at 13:08 • Glen can you be more specific? – Chris Dec 9 '14 at 3:55 • Alecos the leftover rolls are sold on the second day – Chris Dec 9 '14 at 3:58 • @Chris Are you sure you want to do this to yourself?!:)... How about I post the solution to the simpler static set up that I outlined in my comment, and you see if you can modify it for the dynamic case? And we' ll take it from there. – Alecos Papadopoulos Dec 9 '14 at 15:18 ## 1 Answer I will present a solution under the simplyfying assumptions that I proposed in a comment: No inventories are carried over to the next day. "Demand" is "demand for fresh rolls", while "left overs" induce extra demand at the end of the day, due to their very low price, exactly equal to their quantity. So all rolls are sold the day they are produced (non-destroyed, or carried over). Denote$X$the demand for fresh rolls,$q$quantity of units produced in a day,$p_f$the selling unit price of fresh rolls,$p_l$the selling unit price of left-overs, and$c$the common unit costs. We leave the matter of units for the end, to be made consistent with the distributional assumption (which approximates a discrete situation with a continuous random variable). Denote$F(x)$and$f(x)$the CDF and PDF of$X$respectively. Treating the unit of rolls as a continuous variable, the profit function of the bakery (not the expected profit function) is $$\pi = \big[p_fX + p_l(q-X)- cq\big]\cdot I_{\{X\leq q\}} + (p_f-c)q\cdot I_{\{X> q\}}$$ $$=\big[(p_f-p_l)X + p_lq\big]\cdot I_{\{X\leq q\}} + p_fq\cdot I_{\{X> q\}} - cq \tag{1}$$ where we have used indicator functions to separate the two possible states of the world (demand lower or higher than production). The expected profit is therefore $$E(\pi) = (p_f-p_l)E[X\cdot I_{\{X\leq q\}}] + p_lq\cdot E[I_{\{X\leq q\}}] + p_fq\cdot E[I_{\{X> q\}}]- cq$$ $$=(p_f-p_l)\int_0^qxf(x)dx\;+\;p_lqF(q)\; + \;p_fq\cdot[1-F(q)]\; -\;cq$$ Differentiating with respect to$q$which is our decision variable we have $$\frac {\partial E(\pi)}{\partial q} = (p_f-p_l)qf(q)+ p_lF(q) + p_lqf(q) + p_f\cdot[1-F(q)] - p_fqf(q) -c$$ The first term cancels off with the third and fifth so we are left with $$\frac {\partial E(\pi)}{\partial q} = p_lF(q) + p_f\cdot[1-F(q)] -c$$ The first-order condition for maximization is $$\frac {\partial E(\pi)}{\partial q} = 0 \Rightarrow \frac {p_f-c}{p_f-p_l} = F(q^*) \Rightarrow q^* = F^{-1}\left(\frac {p_f-c}{p_f-p_l}\right) \tag{2}$$ while the second-order condition is satisfied for any$q$. We turn to making sense of the distributional assumption. @Glen_b proposed in a comment that given how the parameter$\theta$of the distribution is defined, the "shape-rate" parametrization of the Gamma distribution is implied. And, as usual, he is right because this is consistent with the concept of "units of rolls demanded per day", since in the shape-rate parametrization we have (writing as a physicist would) $$E(X) = \frac {\alpha}{\theta \frac {\text{day}}{\text{rolls-units}}} = \frac {\alpha}{\theta}(\text{rolls-units}/\text{day}) = 6\, (\text{thousand of dozens}/\text{day})$$ The fact that$X$is measured in units of$1,000$dozens and not$1$dozen, does not affect the ratio$\frac {p_f-c}{p_f-p_l}$(the$1,000$factor cancels out), but it will determine the units in which the optimal production will be measured, for which we have $$q^* : q^* = F^{-1}(3/4)$$ and$F^{-1}$being the inverse CDF of a Gamma distribution with shape$\alpha = 3$and rate$\theta =0.5$. Note already that the above implies that, given the structure of revenues and costs, production is optimally to be set so as there is only$25$% probability that the bakery will lose sales, and$75$% probability that the bakery will have to sell some of its production at a loss. This should be intuitive since profit per fresh dozen sold is$3$while loss per left-over dozen sold is$-1$: asymmetry. If I am not making any mistake, we should obtain$q^* = 7.84$(thousands of dozens), a value$\approx 31$% higher than the expected value of$X$. This is a good example to remind us that, even if we deal in expected-value terms (we wanted to maximize the expected value of profits), the expected value$E(X)$is not, in general, the maximizer in such kinds of very real problems. It is one situation to strive for scientific accuracy (where usually, underpredicting is considered equally "bad" with overpredicting, and "deviation-cost" functions are symmetric), and it is an altogether different situation where the deviation costs are asymmetric, as is the case with almost all economic problems like the one above. SIMULATION I generated$1,095$observations from a Gamma as specified in the question. Then I calculated profits for$q^*_1=7.84$and$q^*_1= E(X) = 6$. I obtained for daily profits using$(1)$$$q^*_1=7.84, \;\; \bar \pi = 13.42, \;\; s_{\pi} = 8.75$$ For$\sim 8$% of days the operation made a loss. In comparison $$q^*_1=6, \;\; \bar \pi = 12.7, \;\; s_{\pi} = 6.21$$ The operation made a loss for$\sim 4$% of days. Conclusion: more conservative operation, less variability, less nerve-wrecking experiences (losses), less profits. Should I consider this as a... mathematical proof of the value of venturous entrepreneurship (whatever that may mean)? • Thanks for such a thorough analysis. Although I don't have much experience with econometrics the first part of your solution seems intuitive enough (set the partial derivative of the variable of interest to 0). Can you describe the Poisson process that is the basis of the Gamma distribution? I'm still trying to understand how the Gamma distribution you described would look as a shape, scale gamma, and as a simple Exponential and Poisson. – Chris Dec 11 '14 at 15:17 • There are free density calculators all over the web, that also produce diagrams and function graphs. Try them with the scale parameter set to$2$. – Alecos Papadopoulos Dec 11 '14 at 15:26 • It's not the distribution calculation or visualization that I am having trouble with, it is the process as a whole. For example let's say I have we have a Poisson distribution describing demand for rolls as 1000 units / day. In this case$\lambda$is 1000. We then have an Exponential with$\theta = 1/1000$which describes the wait time between each roll (1/1000 of a day). In this case would we have a Gamma where$X$is the wait time in days before$\alpha$rolls are sold given a scale of$\theta = 1/1000\$? What would then be the analogous process for this question? – Chris Dec 11 '14 at 15:32
• This seems a different issue. I don't understand what "waiting times" have to do with maximizing expected profits in this problem. – Alecos Papadopoulos Dec 11 '14 at 15:45
• I agree the question of how the distributions are related are a different sort of question. Thanks for you help. – Chris Dec 11 '14 at 19:00