A store offers a new seasonal product featured. Let $N$ be the random variable which means the number of clients who come to the store during the season, where $N∼Poisson(27)$. It is estimated that the probability that a customer buys the new product is $p=0.7167$ regardless from a customer to another.

X: The number of customers who purchase the product ;

Y: The number of customers who do not buy the product.

Each unit sold generates a profit of 20\$, and each unit that hasn't been sold by the end of the season costs 8\$ to store until the next season.

What is the number of units n should the store have at the start of the season to maximize average profits?

My answer: I found that X,Y are independent Poisson-distributed random variables :



I found the loss function to be :

$L(X,n) =$ \begin{array}{rcl} 20(X-n) & \mbox{for} & X>n \\ 8(n-X) & \mbox{for} & X\leq n \end{array}

I know I want to find $\frac{d}{dn}E[L(X,n)]=0$ to minimize average loss and by doing so maximize average profit. However I am not sure if this is the right method to take, or on how to proceed from here.

Any help is appreciated

  • $\begingroup$ Why does $X$ have a Poisson distribution? Isn't $X | N \sim Bin(N, p)$? I imagined the situation like this: given a number of customers N and products n the probability for each product to be bought is p = 0.7167. So $\xi_{i} = \mathbb{1}[i-th \ customer \ bought \ a \ product]$, then $X = \sum\limits_{i=1}^{\min(n, N)} \xi_{i}$. If $\xi_{i} \sim Bern(p) \Rightarrow X \sim Bin(N, p)$. $\endgroup$
    – Joitandr
    Commented Aug 20, 2020 at 8:50
  • $\begingroup$ Refer to this previous question I've asked that answers this : math.stackexchange.com/questions/3760761/… $\endgroup$
    – Sol
    Commented Aug 21, 2020 at 23:29

1 Answer 1


The difficulty in your approach lies is that to solve $\frac{d}{dn}E[L(X,n)]=0$ you most likely have to calculate the closed form of the sum that is $E[L(X,n)]$. If you can not find such a closed form, then you should instead look at the difference $E[L(X,n+1)] - E[L(X,n)]$.

The probability that $x$ customers buy the product can be seen as a 2 stage experiment, with the first stage selecting how many customers come to the store, and the second stage selecting how many of these customers buy the product. Therefore we have: $$ \mathbb{P}(X=x) = \sum_{n=0}^\infty \mathcal P_{27}(\{n\})\mathcal B_{n,0.7167}(\{x\}) $$ Let $\lambda :=27, p:=0.7167$. Then we have: $$\begin{align} \mathbb{P}(X=x) &= \sum_{n=0}^\infty e^{-λ}·\frac{λ^n}{n!}·\binom{n}{x}·p^x·(1 - p)^{n - x} \\ &= \frac{e^{-λ}·p^x·(1 - p)^{-x}}{x!}·\sum_{n=0}^\infty \frac{λ^n·(1 - p)^n}{(n - x)!} \\ &= \frac{e^{-λ}·p^x·(1 - p)^{-x}}{x!}·\lambda^x (1-p)^x\sum_{n=0}^\infty \frac{λ^{n-x}·(1 - p)^{n-x}}{(n - x)!} \\ &= \frac{e^{-λ}·p^x·(1 - p)^{-x}}{x!}·\lambda^x (1-p)^x\sum_{n=-x}^\infty \frac{λ^{n}·(1 - p)^{n}}{(n )!} \\ &= \frac{e^{-λ}·p^x·(1 - p)^{-x}}{x!}·\lambda^x (1-p)^x\sum_{n=0}^\infty \frac{λ^{n}·(1 - p)^{n}}{(n )!} \\ &= \frac{e^{-λ}·p^x·(1 - p)^{-x}}{x!}·\lambda^x (1-p)^x e^{\lambda (1-p)} \\ &= \frac{e^{-\lambda p}·(p\lambda)^x·}{x!} \\ &= \mathcal P_{\lambda p}(\{x\}) \end{align}$$

Let $n$ be the amount of the product we have in store. If we say that every sold product gives us a value of $20$, and every unsold product costs us $8$, then we have the following expected profit (Let $P(n)$ be the expected profit if we have an amount of $n$ of the product in store):

$$ P(n):=\sum_{x=0}^\infty \mathbb P (X=x) (20\min(x,n)-8\max(n-x,0))\\ = \sum_{x=0}^n \mathbb P (X=x) (20x-8(n-x)) + \sum_{x=n+1}^\infty \mathbb P (X=x) 20n \\ = \sum_{x=0}^\infty \mathbb P (X=x) 20n + \sum_{x=0}^n \mathbb P (X=x) \left(20(x-n)-8(n-x)\right) \\ = 20n + \sum_{x=0}^n \mathbb P (X=x) \left(20(x-n)-8(n-x)\right) \\ = 20n + \sum_{x=0}^n \mathbb P (X=x) 28(x-n) $$

To calculate the $n$ for which $P(n)$ is maximal, we now look at $P(n+1)-P(n)$:

$$\begin{align} P(n+1)-P(n) &= 20 + \sum_{x=0}^{n+1} \mathbb P (X=x) 28(x-(n+1)) - \sum_{x=0}^n \mathbb P (X=x) 28(x-n) \\ &= 20+ \sum_{x=0}^{n} \mathbb P (X=x) 28(x-(n+1)) - \sum_{x=0}^n \mathbb P (X=x) 28(x-n) \\ &= 20+ \sum_{x=0}^{n} \mathbb P (X=x) \big(28(x-(n+1))-28(x-n)\big) \\ &= 20 -28\sum_{x=0}^{n} \mathbb P (X=x) \end{align}$$

Since $\sum_{x=0}^{n} \mathbb P (X=x) $ is monotonically increasing towards 1, we find out that profit first increases, eventually reaches a maximum, and then forever decreases.

Therefore, the biggest integer below $n$ for which the equality $$P(n+1)-P(n) =0 \quad\Leftrightarrow\quad 20 -28\sum_{x=0}^{n} \mathbb P (X=x) =0 \quad\Leftrightarrow\quad \sum_{x=0}^{n} \mathbb P (X=x) = \frac{20}{28} $$ holds is the maximum.

Since $\sum_{x=0}^{n} \mathbb P (X=x) $ is the cumulative distribution function for $\mathcal P_{\lambda p}(\{x\})$, we can look up the point where $\sum_{x=0}^{n} \mathcal P_{\lambda p}(\{x\})=\frac{20}{28}$ in a table.

From there we obtain $n\approx 21.22229747$.

Addendum: I haven't used that $X$ and $Y$ are stochastically independent. If one uses this fact in a clever manner, one can probably shorten the above calculation drastically.

  • $\begingroup$ Thanks! I'm a bit lost as to why we look at $P(n+1)-P(n)$ to calculate $n$ for which $P(n)$ is maximal $\endgroup$
    – Sol
    Commented Jul 19, 2020 at 17:31
  • 1
    $\begingroup$ $P(n+1) - P(n)$ describes how the profit changes when we keep one more element in store. So as long as $P(n+1) - P(n)>0$, our profit increases when we hold more elements in storage. Inversely, $P(n+1) - P(n)<0$ means that keeping one more element in stock decreases our profit. So technically, ,since $n$ is integer, we look for all such $n$ with $P(n+1) - P(n)\le 0$, $P(n-1) - P(n)\ge 0$, as these and only these $n$ are maxima. We could also look for $n$ where $P(n+1)/P(n)\le 1$ and $P(n)/P(n-1)\ge 1$ instead. $\endgroup$
    – Sudix
    Commented Jul 20, 2020 at 0:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .