It is well known that a uniform distribution over the interval $[a,b] \subset \mathbb R$ has pdf
$$f_X(x) = \begin{cases} \dfrac{1}{b-a}, & x \in [a,b] \\[5pt] 0, & \text{otherwise}\end{cases}$$
Clearly, under this distribution any two sub-intervals of $[a,b]$ with the same length have the same probability. My question is, modulo sets of measure $0$, is this the unique pdf with this property (that any two sub-intervals of the same length have the same probability)?
If every two subintervals of the same length have the same probability, then:
Lemma 1: Every interval containing only one point has measure $0$.
Proof: If it had positive measure, then the whole interval $[a,b]$ would have infinite measure. $\blacksquare$
Lemma 2: For $n=1,2,3,\ldots,$ each of the intervals $[k/n,\ (k+1)/n]$ has measure $1/n$.
Proof: $$P\left( \bigcup_{k=0}^{n-1} \left[ \frac k n , \frac{k+1} n \right] \right) = \sum_{k=0}^{n-1} P\left( \left[ \frac k n , \frac{k+1} n \right] \right) - \sum P(\text{intersections}), $$ where the second sum is that of the measures of all intersections of two such intervals. Each such intersection has measure $0$ by Lemma 1. And there are no intersections of three or more, so we can stop there. $\blacksquare$
Next, to show Lemma 3, that each subinterval $[c,d]$ has measure $(d-c)/(b-a)$, proceed by squeezing. I suspect there's a really efficient way to state the details of the proof but I'll have to ponder what it is.
This determines the entire distribution.
Finally, the densities: For any two such densities, what we have shown so far is that their integrals over the same set are always equal: $$ \int_A f(x)\,dx = \int_A g(x)\,dx \text{ for every measurable set } A. $$ Hence $$ \int_A (f(x)-g(x)) \, dx = 0 \text{ for every measurable set }A. \tag 1 $$ Now let $B = \{x\in[a,b] : f(x) > g(x) \}$ and $C=\{x\in[a,b] : f(x) < g(x)\}.$
Now we only need to show that $P(B)=0$, and by the same argument, $P(C)=0.$
We have
$$ B = \bigcup_{n=1}^\infty \left\{ x\in[a,b] : f(x) - g(x) > \frac 1 n\ \&\ f(x)\not > \frac 1 {n-1} \right\}, $$ where, in the case $n=1$, we construe $f(x)\not > \dfrac 1 {n-1}$ to be vacuous.
If $B$ has positive measure, then one of these sets whose union is taken has positive measure, and then $(1)$ fails to hold when $A$ is that set.
And similarly for $C$.