TITLE: How do you differentiate the likelihood function for the uniform distribution in finding the M.L.E.?
QUESTION [7 upvotes]: There is a classic problem:
Suppose that $X_1,\ldots,X_n$ form an i.i.d. sample from a uniform distribution on the interval $(0,\theta)$, where $\theta>0$ is unknown. I would like to find the MLE of $\theta$.
The pdf of each observation will have the form:
$$
f(x\mid\theta) = 
\begin{cases}
1/\theta\quad&\text{for }\, 0\leq x\leq \theta\\
0 &\text{otherwise}.
\end{cases}
$$
The likelihood function therefore has the form:
$$
L(\theta) =
\begin{cases}
1/\theta^n \quad&\text{for }\; 0\leq x_i \leq \theta\;\; \text{for all }i,\\
0 &\text{otherwise}.
\end{cases}
$$
The general solution is usually that the MLE of theta must be a value of $\theta$ for which $\theta \geq x_i$ and which maximizes $1/\theta^n$ among all such values. 
The reasoning is that since $1/\theta^n$ is a decreasing function of $\theta$, the estimate will be the smallest possible value of $\theta$ such that $\theta\geq x_i$.
Therefore, the mle of $\theta$, $\hat{\theta}$, is $\max(X_1,\ldots,X_n)$.
Here, I do not understand why we cannot just differentiate the likelihood function with respect to theta and then set it equal to $0$?
Thanks!

REPLY [4 votes]: In addition to Stefan Hansen's great answer (+1), intuitively just think of the following:

As you say $L(\theta)$ is a decreasing function so to maximize it $\theta$, $\theta$ has to be such that it is as low as possible 
Secondly, given your restriction on the observations (the random variables $x_i$'s), can it be smaller than $max(X_i)$? The answer is no

1 and 2 imply that even though you might obtain a value of $\theta$ by differentiating so as to obtain a larger likelihood, respecting the second restriction implies that this value is not reasonable.