\documentclass[parskip=full,abstract=on]{scrartcl}

\usepackage[inline]{enumitem}
\usepackage{amsmath}
\usepackage{nicefrac}
\usepackage{natbib}
\usepackage{amsthm}
\usepackage[dvipsnames]{xcolor}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}

\begin{document}

\title{Dynamic pricing with online learning of customer arrival rate
  and acceptable price} 
\author{Behrouz} 
\date{}

\maketitle

\begin{abstract}
  In many industries, the price of commodities are adjusted by taking
  into account the current level of inventory and the distribution of
  future demand. This has motivated studies in the area of
  \emph{dynamic pricing}, which among others have been successfully
  applied in airline industry. A common assumption in these studies is
  that the distribution of future demand is known in advance. While
  sometimes this distribution can be learned from historical data in
  advance, there are cases where the selling scenario has unique
  characteristics and the learning can only be achieved as the selling
  process is going on. In this note we will use Bayesian learning to
  update our belief about two distributions: The distribution of
  customer arrivals and the distribution of acceptable price for
  customers. 
\end{abstract}

Dynamic pricing is the practice of adjusting the price of a product in
a timely fashion. It can be best described through an example in
airline reservation, which is a major application domain for such
techniques. The price of airline seats (in the same class,
e.g. economy) depends on the time to departure and the number of empty
seats. For example, if the departure time is approaching and there are
a lot of vacant seats, it is reasonable to decrease the
price. 

Products like airline seats are called \emph{perishable
  products}. Such products have three characteristics which makes them
good targets for dynamic pricing:

\begin{enumerate}
  \item \emph{fixed inventory}: The quantity of product is fixed.
  \item \emph{fixed sale period}: There is a deadline for sale. 
  \item \emph{high profit margin}: The marginal cost for each item is small, and most of revenue turns into profit.
\end{enumerate}

There are two sources of randomness in demand: 
\begin{enumerate*}[label=\textbf{\arabic*)}]
  \item customer arrival rate, 
  \item customer acceptable price distribution.
\end{enumerate*}

It is often assumed that the distributions of these random effects are
known. A notable exception is the work of
\cite{DBLP:journals/eor/Lin06b}, where he assumes a prior on customer
arrival rate and updates the distribution according to the observed
arrivals as the sales goes on. In this note, we build on this work and
in addition to the arrival rate, we also learn the customer
acceptable price.

The rest of this note is organized as follows:
Section~\ref{sec:arrival} summarizes the work of
\cite{DBLP:journals/eor/Lin06b}. In section~\ref{sec:acceptable} we
introduce our extension which allows learning the acceptable
price. 

%% We conclude the note in section~\ref{sec:conclusion} with a
%% discussion and suggestions for further extending the method presented
%% in this note.


\section{The dynamic pricing problem}
\label{sec:arrival}
Before dealing with the learning problems, we will formulate and solve
the dynamic pricing problem assuming that we know the true
distributions for customer arrival and customer acceptable price. 

It is worth emphasizing that the motivation for one of the model
assumptions will become clear in later sections. In the model it is
assumed that the total number of remaining customers follows a
negative binomial distribution. As we will see later, this results
from assuming a gamma prior on the parameter of a Poisson
distribution.

\subsection{The model}
These are the model assumptions: The seller has to sell a stock of
items in the time horizon $[0,T]$. Customers arrive according to a
Poisson distribution with the rate $\Lambda$. At each point in time,
the number of remaining customers follows a Gamma distribution with
given time-dependent parameters.  After their arrival, a customer will
buy an item if the product price is below their acceptable price, and
will leave empty-handed otherwise. The acceptable price of customers
are i.i.d random variables with a continuous CDF denoted by $F$. More
formally, when the seller sets the price $p$, the probability that an
arriving customer buys the product is $\bar{F} \equiv 1-F(p)$.


\subsection{Solving the pricing problem by recursion}
\label{sec:solution}
In this section, we summarize the method proposed by
\cite{DBLP:journals/eor/Lin06b} for solving the dynamic pricing
problem with the assumptions mentioned earlier. More specifically, the
total number of customers follows a negative binomial distribution
with parameters $(c, \alpha)$. For a price $p \geq 0$, the probability
that a customer buys the item is $\bar{F}(p) \equiv 1-F(p)$. We denote
the inverse of $\bar{F}$ by $\bar{F}^{-1}(v), 0 \leq v \leq 1$. We
also denote the total expected revenue from an arriving customer by
$g(v) \equiv v \bar{F}^{-1}(v)$.

Let $J(s, c, \alpha)$ denote the optimal expected revenue when there
are $s$ items to sell, and the total customers follows a negative
binomial distribution with parameters $(c, \alpha)$. Then the
following recursion holds (see appendix~\ref{appendix:recursion} for
details):

\begin{align}
  \begin{split}
    J(s, c, \alpha) = \alpha J(s, c-1, \alpha) &+ (1-\alpha) 
    \max_{v} \Big( v\big( \bar{F}^{-1}(v) + J(s-1, c, \alpha) \big) + (1-v) J(s, c, \alpha) \Big) \\
    = \alpha J(s, c-1, \alpha) &+ (1-\alpha) J(s,c,\alpha) \\
    &+ (1-\alpha) \max_{v} \Big( g(v) - v\big( J(s,c,\alpha) - J(s-1, c, \alpha) \big) \Big)
  \end{split}
  \label{eq:optimization}
\end{align}

The optimization problem consists of finding a $v$ that minimizes
$g(v) p- v\big( J(s, c, \alpha) - J(s-1, c, \alpha) \big)$. Let us
denote the optimal policy by $v^*(s,c,\alpha)$. Taking the derivative
with respect to $v$ we obtain:
\begin{equation}
  g'\big(v^*(s, c, \alpha)\big) = J(s,c,\alpha) - J(s-1, c, \alpha)
\end{equation}

Substituting $J(s,c,\alpha) = g'\big(v^*(s, c, \alpha)\big) + J(s-1,
c, \alpha)$ back in equation~\ref{eq:optimization} shows that
$v^*(s,c,\alpha)$ satisfies the following equation:

\begin{equation}
  \alpha \big( g'(v) + J(s-1, c, \alpha) \big) = 
  \alpha J(s, c-1, \alpha) + (1-\alpha) (g(v)-vg'(v))
  \label{eq:recursion}
\end{equation}

Equation~\ref{eq:recursion} gives a way to recursively compute the
value of $J(s,c,\alpha)$ in terms of $J(s-1, c, \alpha)$ and $J(s,
c-1, \alpha)$. The base cases for this recursion are:
\begin{equation}
  J(s, 0, \alpha) = J(0, c, \alpha) = 0, \quad c \geq 0, s \geq 0
\end{equation}

Now that we have a means for choosing the price given the negative
binomial distribution for the number of customers, we can plug-in the
learned distribution of equation~\ref{eq:negative_binomial} into this
formula. The optimal value for variable $v$ at time $t$ is equal to:

\begin{equation}
  v^* \Big( s, k+i+1, \frac{a+t}{a+T} \Big)
\end{equation}

To implement this policy, the seller needs to set a price at each time
step. At time $t$, if there exist $s$ items to sell and $i$ customers
have shown up so far, the optimal price is given by:

\begin{equation}
  \bar{F}^{-1} \Big( v^*\big( s, k+i+1, \frac{a+t}{a+T} \big)  \Big)
\end{equation}

\section{Learning the arrival rate}
Since the conjugate prior for Poisson distribution is Gamma
distribution, \cite{DBLP:journals/eor/Lin06b} assumes a Gamma prior on
the arrival rate of customers (i.e. the parameter $\Lambda$). With a
Gamma prior with parameters $(k, a)$, the distribution of arrival rate
will be given by equation~\ref{eq:arrival}.

\begin{equation}
f_{\Lambda} (\lambda) = \frac{a e^{-a\lambda}(a\lambda)^{k-1}}{\Gamma(k)}
\label{eq:arrival}
\end{equation}

It is known that a Gamma mixture of Poisson distributions gives rise
to a negative binomial distribution. In our setting this is the case
for the total number of customers, $N$.

\begin{align}
  \begin{split}
  P(N=n) &= \int_{0}^{\infty} P(N=n|\Lambda=\lambda) f_{\Lambda}(\lambda) d\lambda \\
         &= \int_{0}^{\infty} e^{-\lambda T} \frac{(\lambda T)^n}{n!} 
         \frac{ae^{-a\lambda}(a\lambda)^{k-1}}{\Gamma(k)} d\lambda \\
         &= \frac{\Gamma(n+k)}{n! \Gamma(k)} \Big(\frac{a}{a+T}\Big)^k \Big(\frac{T}{a+T}\Big)^n
  \end{split}
  \label{eq:mixture}
\end{align}

If $k$ is an integer, equation~\ref{eq:mixture} is equivalent to a
negative binomial distribution with parameters $(k,
\nicefrac{a}{a+T})$:

\begin{equation}
  P(N=n) = \binom{n+k-1}{n} \Big(\frac{a}{a+T}\Big)^k \Big(\frac{T}{a+T}\Big)^n
\end{equation}

In general, when a Gamma prior with parameters $(\alpha, \beta)$ is
assumed for the rate of a Poisson distribution, observing $n$ values
$x_i$ from the distribution gives a Gamma posterior with parameters
$(\alpha + \sum x_i, \beta + n)$. Using this property we can update
the arrival rate each time that a new customer arrives. More formally,
if $i$ customers have shown up before time $t$ and the $i+1$-th
customer arrives at time $t$, then the posterior of $\Lambda$ will be
a Gamma distribution with parameters $(k+i+1, a+t)$. This in turn
enables us to re-calculate the distribution of the number of future
customers that will show up in the interval $(t, T]$:

\begin{align}
  \begin{split}
    P\big( N(T) &- N(t) = n \mid N(t^-) = i, \text{arrival at time $t$} \big)  \\
    & = \int_{0}^{\infty} 
    \frac{e^{-(T-t)\lambda} {\big((T-t)\lambda\big)}^n}{n!} 
    \frac{(a+t) e^{-(a+t)\lambda} {\big( (a+t)\lambda\big)}^{k+i}}{(k+i)!} d\lambda \\
    & = \binom{n+k+i}{n} \Big(\frac{a+t}{a+T}\Big)^{k+i+1} \Big(\frac{T-t}{a+T}\Big)^n
  \end{split}
  \label{eq:negative_binomial}
\end{align}


\section{Learning the acceptable price}
\label{sec:acceptable}
The work of \cite{DBLP:journals/eor/Lin06b} updates only the arrival
rate of customers according to the observations and assumes that the
distribution of acceptable price (denoted by $F(p)$ earlier) is
known. However, it is admitted in that study that this assumption is
not always valid. An example mentioned there is introduction of a
seasonal garment. In this case is difficult to predict how much money
the customers are willing to pay. The author then suggests this
question as a possible future research direction. 

This problem is investigated by \cite{Babaki:Thesis}. The challenge is
raised by the fact that there were no direct observations of the
acceptable price. Assume that the seller sets a price $p$ and the
acceptable price for a customer is $\hat{p}$. If the customer buys the
item, we will only know that $p \leq \hat{p}$. Similarly, if the
customer does not buy the item, we will know that $p > \hat{p}$. 

The method used by \cite{Babaki:Thesis} is a small modification to a
method that \cite{DBLP:journals/eor/BerkGL07} proposed for Bayesian
learning with censored data in a different setting. In
section~\ref{sec:censored} we will summarize the part from the work of
\cite{DBLP:journals/eor/BerkGL07} which deals with Gamma distributed
censored data.

\subsection{Bayesian learning with censored data}
\label{sec:censored}
Assume that the random variable $X$ has a Gamma distribution with
parameters $(\alpha, \beta)$. However, instead of directly observing
$X$, we observe $M = \min(s, X)$. The density of the observed variable
$M$ can be written as:

\begin{equation}
  f_{M} (y \mid \alpha, \beta) = 
  \begin{cases}
    \frac{\beta^{\alpha}}{\Gamma(\alpha)} e^{-\beta y} y^{\alpha - 1} & \quad \mathrm{if} \, y < s \\
    \int_{s}^{\infty}  \frac{\beta^{\alpha}}{\Gamma(\alpha)} e^{-\beta x} x^{\alpha - 1} \, dx
    & \quad \mathrm{if} \, y = s \\
  \end{cases}
\end{equation}

We will present a theorem from \cite{DBLP:journals/eor/BerkGL07} (the
proof is presented in appendix~\ref{appendix:proof_censored}):
\begin{theorem}
  Suppose random variable $M$ has a gamma distribution with known
  shape parameter $\alpha$ and random scale parameter $\beta$, where
  the prior distribution for $\beta$ is also gamma, with shape and
  scale parameters $\gamma$ and $\tau$ respectively. Then
  \begin{enumerate}[label=\textbf{\alph*)}]
    \item The posterior distribution of $\beta$ is given as:
      \begin{equation}
        f_{M} (y \mid \alpha, \gamma, \tau) = 
        \begin{cases}
          \frac{\beta^{\alpha+\gamma-1}}{\Gamma(\alpha+\gamma)} 
          e^{-(\tau+y)\beta} (\tau+y)^{\alpha+y} 
          & \quad \mathrm{if} \, y < s \\
          \frac{\beta^{\alpha+\gamma-1}}{\Gamma(\gamma) \Gamma(\alpha)} 
          \frac{e^{-\tau\beta} \tau^\gamma}{\bar{F}_{B(\alpha,\gamma)}(\nicefrac{s}{(s+\tau)})} 
          \int_{s}^{\infty} e^{-\beta u} u^{\alpha-1} \, du
          & \quad \mathrm{if} \, y = s \\
        \end{cases}
      \end{equation}

    \item The first two moments of the posterior distribution of
      $\beta$ under censoring are given by:
      \begin{align}
        m_1 &\equiv E(\beta \mid M=s, \alpha, \gamma, \tau) 
        = \frac{\gamma}{\tau} \frac{\bar{F}_{B(\alpha, \gamma+1)} 
          (\nicefrac{s}{(s+\tau)})}{\bar{F}_{B(\alpha, \gamma)} (\nicefrac{s}{(s+\tau)})}\\
        m_2 &\equiv E(\beta^2 \mid M=s, \alpha, \gamma, \tau) 
        = \frac{\gamma (\gamma + 1)}{\tau^2} \frac{\bar{F}_{B(\alpha, \gamma+2)} 
          (\nicefrac{s}{(s+\tau)})}{\bar{F}_{B(\alpha, \gamma)} (\nicefrac{s}{(s+\tau)})}
      \end{align}
  \end{enumerate}
  where $B$ is a beta random variable with parameters $(\alpha, \gamma)$.
  \label{theorem:censored}
\end{theorem}

When there is no censoring (that is, $y < s$), the posterior of
$\beta$ is a gamma distribution with shape parameter $\gamma^* =
\alpha + \gamma$ and scale parameter $\tau^* = \tau + y$. In the case
of censoring, the posterior is not a gamma distribution anymore. In
this case, we approximate the posterior by a gamma distribution such
that the first and second moments of this gamma distribution are equal
to the moments of the true posterior. 

Recall that for a gamma distribution with parameters $(\gamma, \tau)$
the first moment is given by $m_1 = \nicefrac{\gamma}{\tau}$ and the
second moment is given by $m_2 = \nicefrac{\gamma (\gamma +
  1)}{\tau^2}$. Hence in the case of censored observations, we
approximate the posterior with a gamma distribution with the following
parameters:
\begin{align}
  \tau^* &= \frac{m_1}{m_2 - m_1^2} \\
  \gamma^* &= \frac{m_1^2}{m_2 - m_1^2}
  \label{eq:moments}
\end{align}

and the posterior distribution will have the following form:
\begin{equation}
  f(x \mid \alpha, \gamma^*, \tau^*) = 
  \frac{\Gamma(\alpha+\gamma^*)}{\Gamma(\alpha)\Gamma(\gamma^*)}
  \frac{1}{x} \Big(\frac{x}{\tau^* + x} \Big)^{\alpha}
  \Big(\frac{\tau^*}{\tau^* + x} \Big)^{\gamma^*}
  \label{eq:approx_posterior}
\end{equation}



\subsection{\color{NavyBlue} Bayesian Learning of Acceptable Price}
\label{sec:price_learning}

\color{NavyBlue}
In this section we modify the method proposed by
\cite{DBLP:journals/eor/BerkGL07} to adapt it to the problem of
learning the acceptable price. This section summarizes the main
contribution of \cite{Babaki:Thesis}.

We assume that the acceptable price of customers follows a gamma
distribution with parameters $(\alpha, \beta)$. Let us denote the
event that a customer buys and item at price $p$ is by $B^{+}_p$ and
its complement by $B^{-}_p$. The probabilities of these events are
given by:

\begin{align}
  P( B^+_p \mid \alpha, \beta) = 
  \int_{p}^{\infty} \frac{\beta^{\alpha}}{\Gamma(\alpha)} e^{-\beta x} x^{\alpha-1} \, dx \\
  P( B^-_p \mid \alpha, \beta) = 
  \int_{-\infty}^{p} \frac{\beta^{\alpha}}{\Gamma(\alpha)}
  e^{-\beta x} x^{\alpha-1} \, dx
\end{align}

The following theorem from \cite{Babaki:Thesis} shows that we can
approximate the posterior distribution for acceptable price in a
manner similar to the method proposed by
\cite{DBLP:journals/eor/BerkGL07} (the proof is very similar to the
proof of theorem~\ref{theorem:censored} and is dropped for brevity):

\begin{theorem}
  Suppose the acceptable price has a gamma distribution with known
  shape parameter $\alpha$ and random scale parameter $\beta$, where
  the prior distribution for $\beta$ is also gamma, with shape and
  scale parameters $\gamma$ and $\tau$ respectively. Then
  \begin{enumerate}[label=\textbf{\alph*)}]
  \item If a customers buys an item at price $p$, the posterior
    distribution of $\beta$ is given by:
    \begin{align}
          f(\beta \mid p, \alpha, \gamma, \tau) = 
          \frac{\beta^{\alpha+\gamma-1}}{\Gamma(\gamma) \Gamma(\alpha)} 
          \frac{e^{-\tau\beta} \tau^\gamma}{\bar{F}_{B(\alpha,\gamma)}(\nicefrac{p}{(p+\tau)})} 
          \int_{p}^{\infty} e^{-\beta u} u^{\alpha-1} \, du
    \end{align}

  \item If a customer buys an item at price $p$, the first and second
    moments of posterior distribution of $\beta$ are given by:
    \begin{align}
      m_1 &\equiv E(\beta \mid p, \alpha, \gamma, \tau) 
      = \frac{\gamma}{\tau} \frac{\bar{F}_{B(\alpha, \gamma+1)} 
        (\nicefrac{p}{(p+\tau)})}{\bar{F}_{B(\alpha, \gamma)} (\nicefrac{p}{(p+\tau)})}\\
      m_2 &\equiv E(\beta^2 \mid p, \alpha, \gamma, \tau) 
      = \frac{\gamma (\gamma + 1)}{\tau^2} \frac{\bar{F}_{B(\alpha, \gamma+2)} 
        (\nicefrac{p}{(s+\tau)})}{\bar{F}_{B(\alpha, \gamma)} (\nicefrac{p}{(p+\tau)})}
    \end{align}


  \item If a customers refuses to buy an item at price $p$, the
    posterior distribution of $\beta$ is given by:
    \begin{align}
          f(\beta \mid p, \alpha, \gamma, \tau) = 
          \frac{\beta^{\alpha+\gamma-1}}{\Gamma(\gamma) \Gamma(\alpha)} 
          \frac{e^{-\tau\beta} \tau^\gamma}{\bar{F}_{B(\alpha,\gamma)}(\nicefrac{p}{(p+\tau)})} 
          \int_{-\infty}^{p} e^{-\beta u} u^{\alpha-1} \, du
    \end{align}


  \item If a customer refuses to buy an item at price $p$, the first
    and second moments of posterior distribution of $\beta$ are given by:
    \begin{align}
      m_1 &\equiv E(\beta \mid p, \alpha, \gamma, \tau) 
      = \frac{\gamma}{\tau} \frac{F_{B(\alpha, \gamma+1)} 
        (\nicefrac{p}{(p+\tau)})}{F_{B(\alpha, \gamma)} (\nicefrac{p}{(p+\tau)})}\\
      m_2 &\equiv E(\beta^2 \mid p, \alpha, \gamma, \tau) 
      = \frac{\gamma (\gamma + 1)}{\tau^2} \frac{F_{B(\alpha, \gamma+2)} 
        (\nicefrac{p}{(p+\tau)})}{F_{B(\alpha, \gamma)} (\nicefrac{p}{(p+\tau)})}
    \end{align}

  \end{enumerate}
  where $B$ is a beta random variable with parameters $(\alpha, \gamma)$.
  \label{theorem:price}
\end{theorem}

After obtaining the moments using this theorem, we can approximate the
posterior distribution of acceptable price using equations
\ref{eq:moments} and \ref{eq:approx_posterior}.  
\color{black}

\newpage
\section{Appendices}
\label{sec:appendix}

\subsection{The recurrence relation~\ref{eq:optimization}}
\label{appendix:recursion}

In this section we will see why the following recurrence relation holds:
\begin{align}
  \begin{split}
    J(s, c, \alpha) &= \alpha J(s, c-1, \alpha) \\
    &+ (1-\alpha) 
    \max_{v} \Big( v\big( \bar{F}^{-1}(v) 
    + J(s-1, c, \alpha) \big) + (1-v) J(s, c, \alpha) \Big)
  \end{split}
  \label{eq:recursion}
\end{align}

Recall that the total number of remaining customers follows a negative
binomial distribution with parameters $(c, \alpha)$. The distribution
of this variable is
\begin{equation}
  P(X=i) = \binom{i+c-1}{i} \alpha^c (1-\alpha)^i \quad i = 0, 1, 2, \ldots
\end{equation}

The random variable $X$ can be interpreted as the number of failures
before the $c$th success. Note that each \emph{`success'} will reduce
the first parameter of the negative binomial distribution by one.

At each time, there is an $\alpha$ chance for \emph{`success'}, that
is, a chance that the distribution of remaining customers changes into
a negative binomial with parameters $(c-1, \alpha)$. This is reflected
by $\alpha J(s, c-1, \alpha)$ in
equation~\ref{eq:recursion}. Otherwise, we should set a price for the
arriving customer. We do this indirectly by setting the probability
that the customer will accept the price. If the customer accepts the
price, we will immediately obtain a profit of $\bar{F}^{-1}(v)$ which
we sum with expected future profit $J(s-1, c, \alpha)$. Otherwise we
will only have the expected future profit $J(s, c, \alpha)$.x

\subsection{Proof of theorem~\ref{theorem:censored}}
\label{appendix:proof_censored}

To simplify the proof, we first present this lemma from
\cite{DBLP:journals/eor/BerkGL07}:

\begin{lemma}
  Let
  \begin{equation}
    I(\alpha, \gamma, \tau, s) = \int_{s}^{\infty} 
    \frac{x^{\alpha-1} \tau^{\gamma}}{(\tau+x)^{\alpha+\gamma}} \, dx
  \end{equation}
  Then 
  \begin{equation}
    I(\alpha, \gamma, \tau, s) = 
    \frac{\Gamma(\alpha) \Gamma(\gamma)}{\Gamma(\alpha + \gamma)} P(B > \nicefrac{s}{(s+\tau)})
    = \frac{\Gamma(\alpha) \Gamma(\gamma)}{\Gamma(\alpha + \gamma)} \bar{F}_{B(\alpha, \gamma)} (\nicefrac{s}{(s+\tau)})
  \end{equation}
  where $B$ is a beta random variable with parameters $\alpha$,
  $\gamma$ with the tail probability given by $\bar{F}_{B(\alpha,
    \gamma)} (\nicefrac{s}{(s+\tau)})$.
  \label{lemma}
\end{lemma}

\begin{proof}
  \begin{equation}
  \int_{s}^{\infty} \frac{x^{\alpha-1} \tau^{\gamma}}{(\tau+x)^{\alpha+\gamma}} \, dx
  = \int_{s}^{\infty} \Big(\frac{x}{\tau+x} \Big)^{\alpha-1} \Big(1-\frac{x}{\tau+x} \Big)^{\gamma-1}
  \frac{\tau}{(\tau+x)^2} \, dx
  \end{equation}
  By substituting $y = \frac{x}{\tau+x}$, we obtain:
  \begin{align}
    \begin{split}
      I(\alpha, \gamma, \tau, s) &= 
      \int_{\nicefrac{s}{s+\tau}}^{\infty} y^{\alpha-1} (1-y)^{\gamma-1} \, dy \\
      &= \frac{\Gamma(\alpha)\Gamma(\gamma)}{\Gamma(\alpha+\gamma)} 
      \int_{\nicefrac{s}{s+\tau}}^{\infty} 
      \frac{y^{\alpha-1} (1-y)^{\gamma-1}}{B(\alpha, \gamma)} \, dy \\
      &= \frac{\Gamma(\alpha)\Gamma(\gamma)}{\Gamma(\alpha+\gamma)} 
      \bar{F}_{B(\alpha, \gamma)} (\nicefrac{s}{(s+\tau)})
    \end{split}
  \end{align}
\end{proof}

Now we can prove the theorem~\ref{theorem:censored}:
\begin{proof}
  The joint distribution of $M$ and $\beta$ is given by
  \begin{equation}
    f_M (y, \beta \mid \alpha, \gamma, \tau) = 
    \begin{cases}
      \frac{\beta^{\alpha+\gamma-1}}{} e^{-(\tau+y)\beta} (\tau+y)^{\alpha+\gamma} & 
      \quad \mathrm{if} \, y < s \\
      \int_{s}^{\infty} \frac{\beta^\alpha \tau^\gamma}{\Gamma(\alpha)\Gamma(\gamma)}
      e^{-\beta(\tau+x)} x^{\alpha-1} \beta^{\gamma-1}\, dx &
      \quad \mathrm{if} \, y = s
    \end{cases}
  \end{equation}
  and the marginal distribution of $M$ is given by
  \begin{equation}
    f_M(y \mid \alpha, \gamma, \tau) = 
    \begin{cases}
      \frac{\Gamma(\alpha + y)}{\Gamma(\alpha)\Gamma(y)} 
      \frac{y^{\alpha-1}\tau^\gamma}{(\tau+y)^{\alpha+\gamma}} 
      & \quad \mathrm{if} \, y < s \\
      \frac{\Gamma(\alpha + y)}{\Gamma(\alpha)\Gamma(y)}
      \int_{s}^{\infty} \frac{x^{\alpha-1}\tau^\gamma}{(\tau+x)^{\alpha+\gamma}} \, dx 
      & \quad \mathrm{if} \, y = s
    \end{cases}
  \end{equation}
  The proof of part \textbf{a} of theorem~\ref{theorem:censored} is
  obtained by taking the ratio of these two functions. To prove part
  \textbf{b} note that
  \begin{align}
    \begin{split}
      m_1 &= \int_{0}^{\infty} \beta \frac{\beta^{\alpha+\gamma-1}}{\Gamma(\gamma)\Gamma(\alpha)} 
      \frac{e^{-\tau\beta}\tau^\gamma}{\bar{F}_{B(\alpha,\gamma)}(\nicefrac{s}{s+\tau})}
      \int_{s}^{\infty} e^{-\beta u} u^{\alpha-1} \, du \, d\beta \\
      &= \frac{\tau^\gamma}{\Gamma(\gamma)\Gamma(\alpha) 
        \bar{F}_{B(\alpha,\gamma)}(\nicefrac{s}{s+\tau})}
      \int_{s}^{\infty} u^{\alpha-1} \int_{0}^{\infty} \beta^{\alpha+y} 
      e^{-(\tau+u)\beta} \, d\beta \, du \\
      &= \frac{\Gamma(\alpha+\gamma+1)}{\Gamma(\gamma)\Gamma(\alpha) 
        \bar{F}_{B(\alpha,\gamma)}(\nicefrac{s}{s+\tau})}
      \int_{s}^{\infty} \frac{\tau^\gamma u^{\alpha-1}}{(\tau+u)^{\alpha+\gamma+1}} \, du \\
      &= \frac{\Gamma(\alpha+\gamma+1)}{\Gamma(\gamma)\Gamma(\alpha) 
        \bar{F}_{B(\alpha,\gamma)}(\nicefrac{s}{s+\tau})}
      \frac{1}{\tau}I(\alpha, \gamma+1, \tau, s)
    \end{split}
  \end{align}
  The result follows using lemma~\ref{lemma}. The second moment $m_2$ is obtained similarly.
\end{proof}

\bibliographystyle{plainnat}
\bibliography{references}

\end{document}
