Check your results in Problem 1.11(b) with the following "numerical experiment." The position of the oscillator at time t is
x(t)=Acos(ωt).
You might as well take ω=1 (that sets the scale for time) and A=1 (that sets the scale for length). Make a plot of x at 10,000 random times, and compare it with ρ(x).
Hint: In Mathematica, first define
x[t_] := Cos[t]
then construct a table of positions:
snapshots = Table[x[πRandomReal[j]], {j, 10000}]
and finally, make a histogram of the data:
Histogram[snapshots, 100, PDF, PlotRange → {0,2}]
Meanwhile, make a plot of the density function, ρ(x), and, using Show, superimpose the two.