> Am I doing something very wrong?
>
No, you're not doing anything wrong, it looks like the problem is with
the implementation of cumulative-sum. My implementation is a terrible
hack. I've fixed it a bit (and just pushed it out to Github), which
improved the performance, on the 10,000 sample in particular.
My timings:
user=> (dotimes [_ 5] (time (random-walk-plot 10000)))
"Elapsed time: 2812.732 msecs"
"Elapsed time: 2204.218 msecs"
"Elapsed time: 2349.617 msecs"
"Elapsed time: 2077.014 msecs"
"Elapsed time: 2191.742 msecs"
nil
user=> (dotimes [_ 5] (time (random-walk-plot 1000)))
"Elapsed time: 42.859 msecs"
"Elapsed time: 38.165 msecs"
"Elapsed time: 39.342 msecs"
"Elapsed time: 37.942 msecs"
"Elapsed time: 40.004 msecs"
nil
user=> (dotimes [_ 5] (time (random-walk-plot 100)))
"Elapsed time: 3.689 msecs"
"Elapsed time: 3.622 msecs"
"Elapsed time: 3.636 msecs"
"Elapsed time: 3.661 msecs"
"Elapsed time: 3.631 msecs"
David