Did It Work?

You now have three Monte Carlo simulations of Brownian motion. The first gradually moves some particles out of the bag. They start in the middle and gradually disperse as the figures show. They will either bump into the sides or breakthrough depending on the value you used for breakout. If they are allowed through the sides, some will sneak back in again from time to time. Because they stop moving when they get above the bag, you will end up with a line near the top of the window, as shown in the figure on the right:

images/Diffuse/DiffuseSideBySide.png

The stock price simulation has many more parameters. A simulation with time steps of 0.01, a drift of 0.2 (yes, a ...

Get Genetic Algorithms and Machine Learning for Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.