Example 20.4 on p. 264 of Billingsley's book "Probability and Measures"
​
The distribution of the length of the maximum subinterval generated by i.i.d. n uniform random variables on [0,1]
​
By Le Chen.
Crated on Thu 19 Jan 2023 07:37:53 AM CST

First give the cumulative distribution function

In[]:=
ψ[x_,n_]:=Sum[
k
(-1)
Binomial[n+1,k]
n
Max[1-kx,0]
,{k,0,n+1}]

Plots of the CDF' s

In[]:=
Plot[Table[ψ[x,k],{k,1,6}],{x,0,1}]
Out[]=

Plots of CDF and PDF for different n

n = 1

In[]:=
n=1;​​D[ψ[x,n],x]//FullSimplify​​Plot[{%,ψ[x,n]},{x,0,1}]​​Clear[n]
Out[]=
2
1
2
<x<1
0
x>1||2x<1
Indeterminate
True
Out[]=

n = 2

In[]:=
n=2;​​D[ψ[x,n],x]//FullSimplify​​Plot[{%,ψ[x,n]},{x,0,1}]​​Clear[n]
Out[]=
6-6x
1
2
<x<1
-6+18x
1
3
<x<
1
2
0
x>1||3x<1
Indeterminate
True
Out[]=

n = 3

In[]:=
n=3;​​D[ψ[x,n],x]//FullSimplify​​Plot[{%,ψ[x,n]},{x,0,1}]​​Clear[n]
Out[]=
12
2
(-1+x)
1
2
<x<1
-12(2+x(-10+11x))
1
3
<x<
1
2
12
2
(1-4x)
1
4
<x<
1
3
0
x>1||4x<1
Indeterminate
True
Out[]=

n = 4

In[]:=
n=4;​​D[ψ[x,n],x]//FullSimplify​​Plot[{%,ψ[x,n]},{x,0,1},PlotRangeFull]​​Clear[n]
Out[]=
-20
3
(-1+x)
1
2
<x<1
20(-3+x(21+x(-45+31x)))
1
3
<x<
1
2
20
3
(-1+5x)
1
5
<x<
1
4
20(3+x(-33+(117-131x)x))
1
4
<x<
1
3
0
x>1||5x<1
Indeterminate
True
Out[]=

n = 5

In[]:=
n=5;​​D[ψ[x,n],x]//FullSimplify​​Plot[{%,ψ[x,n]},{x,0,1},PlotRangeFull]​​Clear[n]
Out[]=
30
4
(-1+x)
1
2
<x<1
-30(4+x(-36+x(114+x(-156+79x))))
1
3
<x<
1
2
30(6+x(-84+x(426+x(-924+731x))))
1
4
<x<
1
3
30
4
(1-6x)
1
6
<x<
1
5
-30(4+x(-76+x(534+x(-1636+1829x))))
1
5
<x<
1
4
0
x>1||6x<1
Indeterminate
True
Out[]=