Predicting the size of a uniform distribution from a sample Every bottle of Snapple Iced tea has a fun fact with a fact number on its cap. 
Ex) #939 The penny was the first U.S. coin to feature the likeness of an actual person.
I always wondered just how many facts there were in total (i.e. what the highest number was), and if there was a fact #1 (i.e. the distribution includes 1). So I started collecting the caps from friends and logging their numbers.
If I assume that the distribution of Snapple facts is random and rectangular (i.e. I have an equal probability of receiving any given fact number within the range of available fact numbers), can I approximate the upper and lower bounds of the population space by collecting a sample of caps?
How?
Thank you!
 A: This question ultimately boils down to: what is the largest number you've seen? And how many caps have you collected?
In mathematical terms, your question becomes the following:
$$\text{If } X_1,X_2,...,X_n \text{~iid } U(\Theta) \text{, what function } f=h(\vec x)\text{ is the 'best' estimate of }\Theta?$$
As @kjetilbhalvorsen has pointed out, a natural first guess would be $$h(\vec x) = \max_{i\leq n}x_i$$
Note that the distribution of this variable (since it is an order statistic) is
$$p_H(h) = n\left(\frac{h}\Theta\right)^{n-1}\frac1\Theta = n\frac{h^{n-1}}{\Theta^n}$$
So $$E[H] = \int_0^\Theta h\cdot n\frac{h^{n-1}}{\Theta^n} dh = \int_0^\Theta n\frac{h^{n}}{\Theta^n} dh= \frac{n}{n+1}\Theta$$
Unfortunately, $$E[H] = \frac{n}{n+1}\Theta \neq \Theta$$ Conveniently since $E[k\cdot H] = k\cdot E[H]$,
we can make the following adjustment $h:= \frac{n+1}{n}\max_{i\leq n}x_i$ so that
$$E[H] = \Theta$$ as desired. It turns out this estimator meets the Cramer-Rao boundary, which allows us to conclude it is the minimum variance unbiased estimator of $\Theta$, in other words, you can't get any better than this.
Confidence intervals can also be made, although the lower boundary is obviously $\max_{i\leq n}x_i$ since the maximum value must be larger than or equal to this boundary.
A: What you have is a sample from a uniform distribution (on the integers in the range of) $[0, M]$, say, where $M>0$ is the (integer) upper bound. If $x_1, \dots, x_n$ is a sample from that distribution, you can estimate $M$ as the maximum of the sample. That will be an biased estimator, especially if $n$ is small you can get a better estimator by constructing an unbiased estimator based on the maximum. That I leave for you as an exercise ...
