random walks and more about data vizualization secondsif she takes many stepsis she likely to move ever further from the originor is she more likely to wander back to the origin over and overand end up not far from where she startedlet' write simulation to find out before starting to design programit is always good idea to try to develop some intuition about the situation the program is intended to model let' start by sketching simple model of the situation using cartesian coordinates assume that the farmer is standing in field where the grass hasmysteriouslybeen cut to resemble piece of graph paper assume further that each step the farmer takes is of length one and is parallel to either the -axis or -axis the picture on the left depicts farmer standing in the middle of the field the smiley faces indicate all the places the farmer might be after one step notice that after one step she is always exactly one unit away from where she started let' assume that she wanders eastward from her initial location on her first step how far away might she be from her initial location after her second steplooking at the smiley faces in the picture on the rightwe see that with probability of she will be units awaywith probability of she will be units awayand with probability of she will be units away soon average she will be further away after two steps than after one step what about the third stepif the second step is to the top or bottom smiley facethe third step will bring the farmer closer to origin half the time and further half the time if the second step is to the left smiley face (the origin)the third step will be away from the origin if the second step is to the right smiley facethe third step will be closer to the origin quarter of the timeand further away three quarters of the time it seems like the more steps the drunk takesthe greater the expected distance from the origin we could continue this exhaustive enumeration of possibilities and perhaps develop pretty good intuition about how this distance grows with respect to the number of steps howeverit is getting pretty tediousso it seems like better idea to write program to do it for us let' begin the design process by thinking about some data abstractions that are likely to be useful in building this simulation and perhaps simulations of other kinds of random walks as usual we should try to invent types that correspond to be honestthe person pictured here is professional actor impersonating farmer why we are using the pythagorean theorem