A random walk is a mathematical formalization of a path that consists in a succession of random steps. A random walk can be a Markov chain or process; it can be on a graph or a group. Random walks can model randomized processes, in fields such as: ecology, economics, psychology, computer science, physics, chemistry, and biology.
Questions tagged [random-walk]
248 questions
13
votes
4 answers
Simulating a Random Walk
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 walk here.
I did the following but I'm not…

user3347124
- 153
- 1
- 2
- 7
11
votes
4 answers
Butterfly pattern appears in random walk using srand(), why?
About 3 years ago I coded a 2D random walk togheter with a coleague in C++, first it seemed to work properly as we obtained a diferent pattern each time. But whenever we decided to increase the number of steps above some threshold an apparent…

Isidre Mas Magre
- 149
- 7
11
votes
2 answers
What is the area covered by a Random walk in a 2D grid?
I am a biologist and applying for a job, for which I need to solve this question. It is an open book test, where the internet and any other resources are fair game. Here's the question - I'm stuck on how to approach it and would appreciate pointers.…

mission1983
- 113
- 7
9
votes
1 answer
Random walk pandas
I am trying to quickly create a simulated random walk series in pandas.
import pandas as pd
import numpy as np
dates = pd.date_range('2012-01-01', '2013-02-22')
y2 = np.random.randn(len(dates))/365
Y2 = pd.Series(y2, index=dates)
start_price =…

Joop
- 7,840
- 9
- 43
- 58
9
votes
2 answers
Python Code: Geometric Brownian Motion - what's wrong?
I'm pretty new to Python, but for a paper in University I need to apply some models, using preferably Python. I spent a couple of days with the code I attached, but I can't really help, what's wrong, it's not creating a random process which looks…

Sebastian Schrön
- 103
- 1
- 1
- 3
7
votes
1 answer
How to repeat 1000 times this random walk simulation in R?
I'm simulating a one-dimensional and symmetric random walk procedure:
y[t] = y[t-1] + epsilon[t]
where white noise is denoted by epsilon[t] ~ N(0,1) in time period t. There is no drift in this procedure.
Also, RW is symmetric, because Pr(y[i] =…

Übel Yildmar
- 491
- 1
- 9
- 24
6
votes
0 answers
How to extend the Random Walk Algorithm to include also pre-segmented images according to this formula?
I have the following formula to extend the mathematical expectaion of the original random walk algorithm which is already implemented in SciKit-Image segmentation.
I tried to implement the Guided random walker algorithm mentioned in this paper by…

Bilal
- 3,191
- 4
- 21
- 49
6
votes
2 answers
Mean Square Displacement as a Function of Time in Python
I have been assigned the following:
"...Plot your final MSD as a function of δt. Include errorbars σ = std(MSD)/√N,
where std(MSD) is the standard deviation among the different runs and N is the
number of runs. N.B.: This is the formula for the…

u02cjk16
- 63
- 1
- 5
6
votes
1 answer
Probability to visit nodes in a random walk on graph
I have a finite undirected graph in which a node is marked as "start" and another is marked as "goal".
An agent is initially placed at the start node and it navigates through the graph randomly, i.e. at each step it chooses uniformly at random a…

cmant
- 453
- 1
- 5
- 11
5
votes
5 answers
Rapidly generating ~ 10^9 steps of a random process in R
I have a following task to perform:
Generate 10^9 steps of the process described by the formula:
X(0)=0
X(t+1)=X(t)+Y(t)
where Y(t) are independent random variables with the distribution N(0,1). Calculate in what percentage of indices t the value…

wojciesz
- 53
- 2
5
votes
2 answers
What is a good algorithm to generate a random path?
I need to generate a random path with 25 segments that never crosses itself between two locations in a 1000x1000 area. What is a good algorithm to do this?
My initial idea, which generates ok results, was to generate a random polygon using the space…

Roland Rabien
- 8,750
- 7
- 50
- 67
5
votes
1 answer
How do I put arena limits on a random walk?
I'm building a biased correlated random walk, and I've managed to build the RW, and bias it for westerly movement.
The issue: I need the walk to be bound on one (or all) side(s).
The current code is:
walk<-function(n.times){
…

Jesse001
- 924
- 1
- 13
- 37
5
votes
1 answer
Generating a Smooth Random Trend (Random Walk) in JavaScript
I am looking for a JavaScript implementation of a random walk/random trend algorithm. I need something that will stick with a trend (so, just plain random deltas are out) while still staying within some specified boundaries.
I tried writing…

Wasabi Fan
- 1,763
- 3
- 22
- 36
5
votes
1 answer
Directed weighted graph walk
I have a connected directed weighted graph. The edge weights represent probabilities of moving between vertices; weights for all edges emanating from a vertex sum up to one. The graph contains two sinks: A and B. For each vertex in the graph, I want…

Don Reba
- 13,814
- 3
- 48
- 61
4
votes
1 answer
Constraining a Random Walk in python, how to make it work?
Here is the code for a random walk I made which I attempted to constrain where -5 < y < 5:
import random
import numpy as np
import matplotlib.pyplot as plt
import math
import decimal
def dirs(x):
return np.array( [math.cos(x), math.sin(x)] )
def…

BoyAcc
- 193
- 7