In [27]:
using Distributions
using PyPlot

In [5]:
function middle()
    xs = rand(Uniform(0, 1), 2)
    abs(xs[1] - xs[2])
end


Out[5]:
middle (generic function with 1 method)

In [45]:
n = 1000000
xs = [abs(rand(Uniform(0, 1)) - rand(Uniform(0, 1))) for i in 1:n]
nbins = 50
plt[:hist](xs, nbins)
mean(xs)


Out[45]:
0.333286143680113