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
2
votes
1 answer
How to do 1D discrete collision detection as efficiently as possible?
I have the following situation. There are M independent random walkers on the discrete domain 0, 1, ..., L. We do this for N identical domains. This results in a matrix X where X[i, j] is the position of walker i on domain j. To make a random step,…

R van Genderen
- 127
- 1
- 6
2
votes
1 answer
Simulating a "random walk"-like model based on varying probabilities in R
I'm relatively new to programming in R. I want to simulate the movement of one individual across a 5x5 grid given that the grid varies in its environmental conditions and that movement from one cell to another is based on the environmental…

Kasia A.
- 23
- 3
2
votes
1 answer
Random walk in a 10X10 array
Write a C program that generates a random walk across a 10x10 array. Initially, the array will contain only dot characters. The program must randomly “walk” from element to element, always going up, down, left, or right by one step. The elements…

Humble
- 39
- 9
2
votes
2 answers
How to calculate confidence intervals for future values of a random walk in Javascript?
I have a random-number-generator hooked up to a simple "random walk" experiment. It looks something like this:
let valueAtStepX = [];
let lastValue = 0;
for (let i = 0; i < 1000; i++) {
let randomDeviationThisStep = Math.floor(Math.random() *…

Venryx
- 15,624
- 10
- 70
- 96
2
votes
1 answer
Problem with C++ seemigly skipping lines in program for calculating thermal equilbirum distrobutions with Monte Carlo Alogrithim
I am writing a piece of code as a part of my linear algebra project. its supposed to use a Monte Carlo algorithm known as the random walk property to calculate thermal equilibrium distributions for a body in static thermal equilibrium. I'm a…

Busher Bridi
- 25
- 4
2
votes
1 answer
Get bad result for random walk
I want to implement random walk and compute the steady state.
Suppose my graph is given as in the following image:
The graph above is defined in a file as follows:
1 2 0.9
1 3 0.1
2 1 0.8
2 2 0.1
2 4 0.1
etc
To read and build…

bib
- 944
- 3
- 15
- 32
2
votes
1 answer
What is membership in community detection?
I am finding it hard to understand what membership and modularity returns and why is it exactly used.
wc <- walktrap.community(karate)
modularity(wc)
membership(wc)
plot(wc, karate)
for the above code I get the following when I execute membership:…

Navin
- 684
- 1
- 11
- 24
2
votes
1 answer
1D Random Walk from Matlab to Python
I have a Matlab code that generates a 1D random walk.
%% probability to move up or down
prob = [0.05, 0.95];
start = 2; %% start with 2
positions(1) = start;
for i=2:1000
rr = rand(1);
down = rr1;
up =…

Spica
- 127
- 2
- 10
2
votes
2 answers
Vectorizing a time series ensemble generator in R
This R script generates ensembles of time series. The series are derived from function f(t) = alpha * f(t-0) + epsilon, where epsilon is a random number from a normal distribution.
The final result is a list of ensembles generated from different…

HAVB
- 1,858
- 1
- 22
- 37
2
votes
1 answer
Using SubPlots With LineCollection
I am trying to plot a random walk constrained to move about a lattice.
To implement this constraint I am using hstack to format the segments for LineCollection from the matplotlib module.
I want four random walks to start in four quadrants all on…

Dexileos
- 25
- 4
2
votes
1 answer
python library for evaluating random walks?
I'm trying to evaluate the probabilities of end locations of random walks but I'm having some trouble with the speed of my program. Basically what I'm trying to do is take as an input a dictionary that contains the probabilities for a random walk(…

Luis F Hernandez
- 891
- 2
- 14
- 29
2
votes
1 answer
General Random Walk generator questions
Alright so I have some general questions on how to continue on my python script for generating a set of random walks. So far, I have in my program a single 1-d random walk that works fine. My question is that I want to create a for loop in order to…

Emerge Into Light
- 27
- 4
2
votes
3 answers
Storing intermediate values in a numpy array
I'm trying to simulate a 2-d random walk, with direction 0 < θ < 2π and T=1000 steps.
a=np.zeros((1000,1000))
def randwalk(x,y):
theta=2*math.pi*rd.rand()
x+=math.cos(theta);
y+=math.sin(theta);
return…
user4142446
2
votes
2 answers
Python: Drunkard's walk
I have to write a code to calculate route and length of a drunkard's walk.
Excersise:
A drunkard begins walking aimlessly, starting at a lamp post. At each time step he takes one step at random, either north, east, south, or west. How far will the…

Markus
- 53
- 1
- 4
2
votes
1 answer
How to stop a random walk
plot(0:70,0:70, type="n", xlab="X", ylab="Y")
x<-40
y<-40
x2<-60
y2<-60
points(x, y, pch=16, col="red", cex=1.5)
points(x2, y2, pch=16, col="green", cex=1.5)
for (i in 1:10000){
xi<-sample(c(1,0,-1),1)
yi<-sample(c(1,0,-1),1)
…

user3210434
- 21
- 1