# MLE for uniform distribution around $[-\theta,\theta]$ [duplicate]

Given $$X_1,\ldots,X_n$$, where $$X_i\sim U(-\theta,\theta)$$, what the MLE for $$\theta$$? Apparently the answer is $$\max\{|X_1|,\dots,|X_n|\}$$ but I can't figure out why.

The density function is $$f(x,\theta) = \begin{cases} \frac{1}{2\theta}, & x\in[-\theta,\theta] \\ 0, & \text{else} \end{cases}$$

I get a likelihood function that may decrease or increase for $$\theta<0$$, depending on the parity of $$n$$. I'm not sure if that's the way to solve this.

## marked as duplicate by StubbornAtom, YuiTo Cheng, Ak19, Shogun, Daniele TampieriJul 19 at 5:07

• The way you define the density $\theta$ has to be positive otherwise the density becomes negative – Grada Gukovic Jul 18 at 13:04

I am assuming the $$X_i$$ are independent.

The likelihood of $$\theta$$ given your observations is $$\mathcal L(\theta|X_1, \dots, X_n)=\prod_{i=1}^{n}f(X_i, \theta).$$ This equals $$=(2\theta)^{-n}$$ if $$\theta \geq |X_i|$$ for all $$i$$, and $$0$$ otherwise. In addition, the larger $$\theta$$, the smaller the above quantity.

In other words, in order to maximize the likelihood you need the smallest value of $$\theta$$ such that the above quantity is not $$0$$, and that is $$\max\{|X_i|;i=1,\dots, n\}$$.

The way you define the density, $$\theta$$ has to be positive. Otherwise the density becomes negative if $$\theta \leq x \leq -\theta$$ and the density function integrates to -1 over $$\mathbb{R}$$.

Assume sample $$X = \{x_1, x_2 ,... , x_n\}$$ and $$|X| = \{|x_1|, |x_2| ,... , |x_n|\}$$ the set of absolute values from the sample.

As $$x \in [-\theta, \theta]$$ $$\forall x \in X$$ , by definition the following has to hold: $$-\theta \leq x \leq \theta \Leftrightarrow |x| \leq \theta$$.(i)

The likelihood function is $$L(x;\theta) = \frac{1}{2\theta}^n$$ The loglikelyhood becomes:

$$l(x;\theta) = nlog((2\theta)^{-1}) = -nlog(2\theta)$$ $$\Rightarrow \hat\theta_{ML} = \underset{\theta \geq max|X|}{\operatorname{argmax}}-nlog(2\theta) = max|X|$$, where the condition for the maximizer comes from applying (i) to the entire sample. The maximizung value max|X| is obtained by the fact that log is a monotonically increasing function and its multiplied by a negative constant.