Example R programs and commands
The mth largest of k independent uniforms is distributed like beta(m,k+1-m)
# All lines preceded by the "#" character are my comments.
# All other left-justified lines are my input.
# All other indented lines are the R program output.
### Theorem:
### If Xi~U([0,1]) is a uniform random variable for i-1,...,k,
### and X1,...Xk are independent, then Z=min(X1,...,Xk) has the
### distribution Z~Beta(1,k), whose p.d.f. is k*(1-t)^(k-1).
### More generally, if Z is the mth smallest for k i.i.d. uniforms,
### then Z~Beta(m,k+1-m). Here Beta(a,b) has p.d.f. C*t^(a-1)*(1-t)^(b-1).
### Illustrate this for some small k by sampling, taking mins
### and comparing the histogram to the graph of dbeta():
N<-10000 # number of mins to simulate
x<-vector("numeric",length=N) # array to hold mins of samples
t<-seq(0,1,by=0.01) # abscissa for the comparison p.d.f. plot
# First trial: min of 5 i.i.d. uniforms
k<-5 # number of independent uniforms
for(n in 1:N) { x[n]=min(runif(5))} # main loop; runif() samples U([0,1])
# Plot the histogram
hist(x,prob=T) # normalize to unit area for comparison with p.d.f.
lines(t,dbeta(t,1,k)) # plot the Beta(1,k) p.d.f. on the same graph
# Second trial: min of 9 i.i.d. uniforms
k<-9
for(n in 1:N) { x[n]=min(runif(k))}
hist(x,prob=T)
lines(t,dbeta(t,1,k))
# Third trial: 3rd smallest of 9 i.i.d uniforms
k<-9
m<-3
for(n in 1:N) { x[n]=sort(runif(k))[m]} # sort increasing; mth smallest
hist(x,prob=T)
lines(t,dbeta(t,m,k+1-m))