I am new to programming inMathematica, and I am trying to pick up a few things by myself. As an exercise, I wanted to generate a two-dimensional random walk starting at the origin, and then moving a unit length randomly in each subsequent step. After that the goal of the exercise is to a) find the distance between the origin and the terminal point and b) if possible, to plot the random walk.
Here's what I thought of doing. Assign a vector a = {0,0} and then add a normalized vector b = Normalize[{RandomReal[], RandomReal[]}], and perform this procedure iteratively.
What I'm having trouble doing is performing the iterations. For instance, in the first step a + b generates c1, in the second I wish to generate c2 = c1 + b, and so on.
Moreover, I want b to be different each time, something I have failed at accomplishing. I'm kinda lost, and don't know where to start, any help would be appreciated.






{}button above the edit window. The edit window help button?is also useful for learning how to format your questions and answers. You may also find this meta Q&A helpful – Michael E2 Jun 19 '16 at 01:56Normalize[{RandomReal[], RandomReal[]}]will not yield a uniformly distributed direction, which is maybe what you want. The right way to generate a uniformly distributed direction would be the method in Wjx's answer, or the cheaperNormalize[RandomVariate[NormalDistribution[], 2]](see this paper for more details). – J. M.'s missing motivation Jun 19 '16 at 02:52{Sin[#], Cos[#]} &@RandomVariate[UniformDistribution[{-\[Pi], \[Pi]}]]? – Sjoerd C. de Vries Jun 19 '16 at 19:22{Sin[#], Cos[#]} & /@ RandomVariate[ UniformDistribution[{-\[Pi], \[Pi]}], {1000000}]; // AbsoluteTimingis about 8 times faster than usingNormalize /@ RandomVariate[NormalDistribution[], {1000000, 2}]; // AbsoluteTiming– Sjoerd C. de Vries Jun 19 '16 at 19:40