Finding the MLE of Uniform distribution 
Let $x_{1} = 2.4$ , $x_{2} = 9.2$ , $x_{3} = 5.2$ , $x_{4} = 4.1$ , $x_{5} = 2.1$, $x_{6} = 3.1$ be the observed values of a random variable of size 6 from the uniform distribution with parameters $(\theta -2,\theta + 6)$ where $\theta>0$  is unknown, then the $MLE$ of $\theta$ is :

I know that for finding MLE we have to differentiate and maximise the logarithm of the likelihood function w.r.t the parameter. But for this question how do you find the likelihood function with the parameter $\theta$ involved.
The PDF of the uniform function is as follows: $$f(x) = \frac{1}{8}$$
Or is there a different way in solving this question?
 A: I assume that the random variables $X_{1}, X_{2},..., X_{6}$ are independent draws from $Unif(\theta-2,\theta+6)$ with $\theta>0$
Then the joint pdf of $X_{1}, X_{2},..., X_{6}$ can be written as
$$f(X_{1},X_{2},...,X_{6};\theta) = \prod_{i=1}^{6}f(X_{i}) = \prod_{i=1}^{6}\frac{1}{8}\mathbb{I}_{X_{i}\in(\theta-2,\theta+6)}$$
where $\mathbb{I}_{X_{i}\in(\theta-2,\theta+6)}=1$ if $X_{i}\in(\theta - 2,\theta  +6)$ and $0$ otherwise.
The goal is to maximize $f(X_{1}, X_{2},...,X_{n};\theta)$ with respect to $\theta$.
If all $X_{i}$ are outside the interval $(\theta-2,\theta+6)$ then all the indicator functons will be zero hence $f(X_{1},X_{2},...,X_{n};\theta)=0$
So, for maximizing the pdf all the $X_{i}$ must be inside the interval $(\theta-2,\theta+6)$. For that to be true the following inequalities must hold
$$\theta-2\leq min(X_{1}, X_{2},...,X_{6})$$ and
$$max(X_{1}, X_{2},...,X_{6})\leq \theta +6$$
$$\Rightarrow \theta \in [3.2,4.1]$$
The derived interval $[3.2,4.1]$ is the only interval that makes the likelihood function $f(X_{1}, X_{2},...,X_{n};\theta)$ being non-zero as it let all the indicator functions equal to $1$.
Just to make sure that the values inside the interval $[3.2,4.1]$ are the ones that maximize the likelihood function $f(X_{1}, X_{2},...,X_{n};\theta)$ we can numerically observe that
x = c(2.4 , 9.2 , 5.2 , 4.1 , 2.1,3.1) 
theta = seq(0.1,10,by=0.1)  
like = rep(1,length(theta)) 
for(i in 1:length(theta)){  
for(j in 1:6){    
like[i] = like[i]*dunif(x[j], min = theta[i]-2, theta[i]+6 , log = FALSE) 
          }
                        } 
plot(like)

