I would like to simulate paths of a Geometric Brownian Motion till it hits one of two barriers, say 10 or 200.
data2 = RandomFunction[
GeometricBrownianMotionProcess[0.05, .15, 100], {0, 10, .01}, 1]
ListLinePlot[data2]

data3 = %69["Path"]
data4 = {}
j = 1; While[data3[[j, 2]] < 200 && data3[[j, 2]] > 10,
data4 = Append[data4, {data3[[j, 1]], data3[[j, 2]]}]; j++]
ListLinePlot[data4]

This works but is clunky and inelegant. Is there someway I can do it better or maybe run the simulation till some barrier is hit instead of truncating the data post simulation?


%69— your%69is not the same for anyone else and they will not be able to run it (also, I save only 1 previous output)... – rm -rf May 11 '13 at 00:25%is the previous input,%%2 inputs prior,%nn inputs prior (all, as indicated by theIn[n]and not by your current position) – rm -rf May 11 '13 at 02:45%nis the nth input not n inputs before current. – Sjoerd C. de Vries May 11 '13 at 06:48