In a plane (two dimensional), a path can be represented by a sequence of (n+1) points (Xo,Yo),(X1,Y1),...,(Xn,Yn) such that, for any i (integer 1 < i < n-1):

```
Pi(vector) = [Xi-X(i-1),Yi-Y(i-1)]
```

representing the ith step, is a vector with the length Pi, and a value of the change of direction between the vectors Pi and P(i+1) is measured algebraically (don't know how) by the turning angle a(i).

Like any angular distribution (of changes of direction) it is characterized by a mean vector which is taken to be symmetrical and to have angular mean Φ = o. The approach to this analysis involves numerical simulations, since the algebraic approach seems to be too complex and I have to use a pseudo-random Gaussian generator to obtain continuous values from a normal distribution with a mean of 0 and a standard deviation σ (0.1-1.2)radians to simulate a path.

So after each step with the length P (is constant i.e 125km), the value of the change of direction (turning angle a(i)) is determined by the pseudo-random generator for a given value of σ, which is constant along the path. And then makes a step in the next direction, and so on.

Some useful equations:

```
a(i) ~ n(0,σ)
Θ(i+1) = Θ(i) + a(i)
X(i+1) = Xi + P Cos[Θ(i+1)]
Y(i+1) = Yi + P Sin[Θ(i+1)]
```

where Θi represents the direction of the ith step. The direction of the first step Θi, is chosen at random according to a uniform angular distribution by a pseudo-random uniform generator. Turning angles are recorded from -Pi to Pi

How can I take i.e 12 families of 500 step paths each characterized by a given value of standard variation σ ranging between 0.1 and 1.2 radians, of the distribution of changes of direction between successive steps and PLOT it in Mathematica? I don't know anything about Mathematica specially how to write the code for this problem.

Following your notations in the question, you use independent normal increments to build an angle, and then use it as a direction for next step of size `size`

.

```
Block[{size=0.5}, Graphics[
Line[Accumulate[
Function[x, size*{Re[x], Im[x]}, Listable][
Exp[I Accumulate[
RandomVariate[NormalDistribution[0, Pi/4], 10^3]]]]]]
]]
```

```
RandomRobinsonWalk[coords_List] :=
Show[CountryData["World", {"Shape", "Robinson"}],
Graphics[{Thick, Red,
Line[Map[ GeoGridPosition[ GeoPosition[#], "Robinson"][[1]] & ,
coords]]}], Frame -> True]
```

Generation of random walk on a sphere is performed as follows:

```
Coordinates[{\[Theta]_, \[Phi]_}, {cosa_,
sina_}, \[CapitalDelta]\[Theta]_] := {ArcCos[
Cos[\[CapitalDelta]\[Theta]] Cos[\[Theta]] -
cosa Sin[\[CapitalDelta]\[Theta]] Sin[\[Theta]]],
ArcTan[cosa Cos[\[Theta]] Cos[\[Phi]] Sin[\[CapitalDelta]\[Theta]] \
+ Cos[\[CapitalDelta]\[Theta]] Cos[\[Phi]] Sin[\[Theta]] +
sina Sin[\[CapitalDelta]\[Theta]] Sin[\[Phi]], (cosa \
Cos[\[Theta]] Sin[\[CapitalDelta]\[Theta]] +
Cos[\[CapitalDelta]\[Theta]] Sin[\[Theta]]) Sin[\[Phi]] -
Cos[\[Phi]] sina Sin[\[CapitalDelta]\[Theta]]]};
Clear[SphereRandomWalk];
SphereRandomWalk[ipos_, steps_, stepsize_, prec_: MachinePrecision] :=
FoldList[Function[{up, cossin}, Coordinates[up, cossin, stepsize]],
ipos, Function[u, {Re[u], Im[u]}, Listable][
Exp[I RandomVariate[UniformDistribution[{-Pi, Pi}], steps]]]]
```

The formula used to obtain the next `{\[Theta], \[Phi}`

pair was obtained as follows:

```
Expand[Simplify[((RotationMatrix[\[Alpha], {Sin[\[Theta]] Sin[\[Phi]],
Sin[\[Theta]] Cos[\[Phi]],
Cos[\[Theta]]}].({Sin[\[Theta]] Sin[\[Phi]],
Sin[\[Theta]] Cos[\[Phi]],
Cos[\[Theta]]} /. {\[Theta] -> \[Theta] + \[CapitalDelta]\
\[Theta]}))) /. {Conjugate -> Identity} /. {Abs[x_]^2 :> x^2}]]
```

that is, perform a fixed size rotation in [Theta] and then rotate around the previous vector by random angle `\[Alpha]`

.

Usage:

```
((# - {90, 0}) & /@ (SphereRandomWalk[{Pi/2, 0} // N, 2500, Pi*0.01]/
Degree)) // RandomRobinsonWalk
```

Sasha's answer is the way to go, but as you are beginning with Mma, perhaps a procedural program is easier to understand.

Please note that I am NOT saying that this is a good way of doing things in Mma.

```
P = 1;
For[iter = 1, iter < 13, iter++,
sigma = iter/10;
a = RandomVariate[NormalDistribution[0, sigma], 500];
Clear[theta, x];
theta[i_] := theta[i] = theta[i - 1] + a[[i]];
x[i_] := x[i] = x[i - 1] + P {Cos[theta[i]], Sin[theta[i]]};
theta[0] = RandomReal[{0, 2 Pi}];
x[0] = {0, 0};
For[step = 1, step < 500, step++,
r[iter, step] = x[step];
]
]
Show@Table[
ListLinePlot[Table[r[s, i], {i, 500}], PlotStyle -> ColorData[1][s],
PlotRange -> 300 {{-1, 1}, {-1, 1}}], {s, 1, 12}]
```

The following code plots your twelve families in different colors and if you hover your mouse over a line you get sigma in a tooltip.

```
Graphics[
Table[
{x, y} = {0, 0};
p = 1;
\[Theta] = RandomReal[{-\[Pi], \[Pi]}];
Tooltip[
{
Hue[\[Sigma]/1.3],
Line[
NestList[(\[Theta] +=
RandomVariate[NormalDistribution[0, \[Sigma]]]; # +
p {Cos[\[Theta]], Sin[\[Theta]]}) &, {x, y}, 500]
]
}, \[Sigma]
],
{\[Sigma], 0.1, 1.2, 0.1}
]
]
```

Similar Questions

How can I generate a random number in Flash CS5 using AS3, I'd prefer it as simple as possible. My attempt gives me an error: day_gross.addEventListener(MouseEvent.CLICK, randomNumber); function rando

I need to make a timer that will exit my program after 3 seconds - when a Bool is set to true - how can I do so? I have tried using a few basic timers in a new class, but this doesn't seem to work. I

How can I generate random 8 character alphanumeric strings in C#?

I'm trying to generate an arraylist of random numbers and display it. I'm not sure where I'm going wrong. I think my showArray method isn't working properly because it's displaying two random numbers

I installed Microsoft SQL Server 2012 and created new database, some new tables & also inserted some values into that table. I want to access that data from Mathematica. I read documentation about

I've been trying for several hours to make a random walk (a path) like this one. From top to down. x 1 x x 2 3 x x 4 7 6 5 8 x x 9 10 x My greatest difficulty is to calculate the displacement from ri

How can this Mathematica code be ported to Python? I do not know the Mathematica syntax and am having a hard time understanding how this is described in a more traditional language. Source (pg 5): ht

This question already has an answer here: Matlab — random walk with boundaries, vectorized 2 answers I have a array of 10 vectors 'x' with as below (for simulating 1D random walk): r=rand(10,10

I have an image which moves in a random direction. My problem is everytime I start running the program, the image always appear at the upper-left corner and moves a diagonal direction and after hittin

I've perused the Stack Exchange list of sites, and I can only think that SO is the right place to ask this (I saw a few excel questions, at least). I have an array of values Sheet1.B3:B9. On another s

I am using a cron command in Ubuntu that is running a python program: 05 23 * * * python /home/ahmed/Desktop/hello.py How do I stop the program from running?

So, I have a small problem here with a rather large for loop. This program is to simulate random walks of 100 steps each - what I want to do is have the program perform 1 million of these random walk

I want to generate a large (~2 kb), random, unique block of random text for use as an authentication token. Standard hashing functions produce results that are too short. Would it be OK to use openssl

I have two tables, custassets and tags. To generate some test data I'd like to do an INSERT INTO a many-to-many table with a SELECT that gets random rows from each (so that a random primary key from o

Based on Martin Smith's answer here, I've been trying to use a very similar technique to creating 10000 random strings that start with two characters(A-Z), then two numbers(0-9) and then two character

I am looking for the prototypical 'Hello World' program that creates a Mathematica Notebook file. I have this working program. package graphica; import com.wolfram.jlink.*; /** * * @author Nilo */ pu

A friend of mine asked me to make a program that would print a string of random 1's and 0's in a matrix like fashion. I agreed and succeeded in writing a program in batch that has the desired output b

How can play sound using JavaScript only, without using the <audio> tag? I'm using: var audio = {}; audio[walk] = new Audio(); audio[walk].src = Scr/dave.wma audio[walk].load() setTimeou

How can I get the Clojurescript namespace I am in from within a clojurescript program? I want to do this do provide certain debug information (it only needs to work in dev mode)

I have seen an answer to this problem for plots, but I want to do it for a general graphics box. Graphics[{Disk[], Red, Rectangle[{-.75, 1}, {.5, -.5}]}, Background -> Green] I would like to make

I have a menu with x number of buttons that all go to different pages the problem is I have to start at the button at the top n go down I'm order for it work without crashing. If I click on the second

I'm using the jQuery validate plugin, and would like to return a random value on success. Right now I'm trying to use: var success_message = new Array (); success_message[0] = Good!; success_messa

I want my Ruby program to do different things on a Mac than on Windows. How can I find out on which system my program is running?

I have a command line program that wants to pickle things when I send it a ctrl-C via the terminal. I have a some questions and concerns: How do I perform this handling? Do I check for a KeyboardInt

Xn can take values of -1 or 1 each with a probability of 0.5. And Sn= Sn-1 + Xn How can I compute the partial sum observed at time n given by Sn = X1 + X2 + : : : + Xn. I'm trying to simulate a random

I'm trying to simulate mutation of two parts a and b in Mathematica. I put in the genetic drift (totally random element) by: p[sim_, 0] = Join[Table[a, {15}], Table[b, {15}]] p[sim_, t_] := p[sim, t]

I have many independent random processes (arrival processes say) that require me to generate random numbers. I want to use common random numbers for each of these processes that I can compare how diff

Can anyone provide suggestions of tools that can be used to make mutations within a Java program at a source-code (not byte-code) level? I need to seed my source code with faults. I would prefer an ap

How can I log file/registry access history for specified EXE program? I want to start specified program and get list/log of accessed files or registry to determine which config life crash this program

This is my first time posting here. I would really appreciate some help with a question from my mathematica study guide. My question is: Suppose that a drunk randomly steps either forward, backward, l

I make program for windows, that work with internet and self local dababase. How i can ensure user, which install program, that my program do not send his data and document thru internet to me. I thin

Now I am using Walk to go through my folder, I want to filter some folder when scan. err := filepath.Walk(/home, func(path string, f os.FileInfo, err error) error { ... }) The folder structure is:

I have a game that displays patterns on the screen based off order. I don't want this order to be very strict to one order like 1 2 3 4 5 6 I would like the order to be more random. So I am trying to

I produce the y coordinates of a random walk using the following code. from random import * n = 10 length = 100*n def ncount(vector): return sum(vector) randBinList = lambda n: [randint(0,1) for b in

I am not sure if that is the right place for this question but I couldn't find any posts on that subject. I want to upload my own program into a digital frame. Any ideas how to do it? Languages ? Int

I was wondering how do I plot these coupled differential equations on Mathematica: http://www.physics.udel.edu/~szalewic/teach/419/cm08ln_quad-drag.pdf If you click on the link above and scroll all th

Python Question I have a function for 1 random step: def random_step(): chooses a random step (-1 or 1) and returns it. inputs: none! However, make sure to use parens when calling it. For example:

I want to access and process information from files in sub-directories from a root directory. I have tried using os.walk, which gets me to the files, but how do I access their contents? I want specifi

How can I check if DatabaseLink`OpenSQLConnection was successful? My code is as follows conn = OpenSQLConnection[JDBC[hsqldb, file], Name-> test]; Can I use something like Head[conn]?

I want to use jquery in my iphone program. Is it possible? If so, anyone help me with some main steps: which files i have to import or something essential. Thanks in advance.

Say I have got a program that hogs the processor and/or hard disk to the point that it makes it nearly impossible to do anything else on that computer. Now I don't want to kill that program because wh

I am creating a desktop app that will sit on a PC and occasionally check a web server for updates to various settings. The program will be using these settings frequently so I would like cache the set

I downloaded a program. Its context menu works fine in Windows XP Explorer, but in Windows 2008, the context menu doesn't appear. It looks like the shell extension on the software isn't compatible wit

How to properly enable syntax highlighting for Mathematica in Vim? I want it automatically on when opening .m files with Vim too.

I am trying to run a remote mathematica kernel between two macs. Under Kernel Configuration Options For kernel program I have: /Applications/Mathematica.app/Contents/MacOS/MathKernel The arguments of

How can I create a random number when I define a global declaration in Uppaal program? I want to have a variable that contains a random number as in C program : int x = rand (100);

UPDATE CattleProds SET SheepTherapy=(ROUND((RAND()* 10000),0)) WHERE SheepTherapy IS NULL If I then do a SELECT I see that my random number is identical in every row. Any ideas how to generate unique

wolfram alpha accepts latex, but it does not export to latex, it exports plaintext,rendered images and mathematica sytax. Is there any javascript library that converts the output to latex? Mathematica

I am looking for the equivalent of the below Matlab function in Mathematica: R = poissrnd(lambda) generates random numbers from the Poisson distribution with mean parameter lambda. lambda can be a ve

How can I have a system tray icon for my program in Java? I've tried searching all over the web ,but I cant find anything.