Questions tagged [random-walk]

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.

248 questions
1
vote
1 answer

Mean square displacement of a 1d random walk in python

I'd like to calculate the mean square displacement at all times of a 1d trajectory. I'm a novice programmer, so I've attempted it from a simulated random walk. import numpy as np import matplotlib.pyplot as plt # generate random walk path =…
Luke
  • 11
  • 2
1
vote
0 answers

Plotting the mean square displacement of a 2D random walk as a function of δt

I've already created a code for random walk of 10000 steps and then repeated it 12 times and stored each run in a separate text file (which was required in the question). I then calculated the mean square displacement of it(not sure if it's done…
KirstyK55
  • 11
  • 2
1
vote
2 answers

RandomWalker Segmentation algorithm results in a segmentation same as the initial seeds

I have a medical Image, and I'm trying to segment a specific zone inside. After several steps of conventional image processing, I was able to locate the region, and managed to get the seeds for the segmentation, but when I try to apply RandomWalker…
Bilal
  • 3,191
  • 4
  • 21
  • 49
1
vote
1 answer

How do I plot the average of a random walk/monte carlo sim Python

I have a problem where I am plotting a random walk and I am looking to get the average line for all the simulations. My code is below: import numpy as np from math import sqrt import matplotlib.pyplot as plt # starting stock price S = 100 # number…
Hektar
  • 71
  • 7
1
vote
1 answer

Random Walk in a 3D spherical coordinates system-Python

I am currently attempting to map and show the path of a photon from the center of the sun until it reaches the surface and is emitted. I also want to show the time taken for this to happen. So far all I have done is set the parameters (density of…
sek1996
  • 11
  • 1
1
vote
0 answers

How to prove that the processes are martingales in Python?

Let S_n be simple random walk. I need to make simulation in Python proving that the following processess are martingales S_n when the random walk is symmetric S_n -n(p-q) (S_n)^2 - 2(p-q)S_n + (n(p-q))^2 - n(1-p+q) for example my code for the…
Thomas
  • 11
  • 2
1
vote
0 answers

Can the parameters for a plot be saved in a passable variable in Python?

In the following expample I would like to assign the arguments passed to the plot in an appropriate datatype. Let his name be "plotargument". How do I assign plotargument correctly so I am able to get the same result from df.plot(plotargument) as…
Dr.Ario
  • 11
  • 5
1
vote
1 answer

How to show two lines overlapping in turtle graphics

Screenshot of output image I made a random walk program using turtle and I want it show where the two turtles cross paths by changing the color. `import turtle as T import random as R t = T.Turtle() u = T.Turtle() t.speed(0) u.speed(0) …
1
vote
1 answer

How to do an efficient random walk in arangodb?

I am working on a graph database on ArangoDB and I'm trying to have paths through a random walk. My purpose is from a start vertex V, I get for instance 4 random paths with a specified depth. As far as from now, I've found the following code that…
Syndo rik
  • 755
  • 1
  • 7
  • 15
1
vote
0 answers

How do I implement the power iteration method in pyspark?

I want to implement an equation similar to the one in the page rank algorithm using pyspark. In tradition way it is simple to implement, but when I come to project the implementation in pyspark I got stuck. Let say we have a Matrix W of dimension…
moudi
  • 137
  • 11
1
vote
2 answers

How can I create a new list every x amount of steps in a loop?

I'm plotting some random walk functions on python and trying to create it so it takes the locations of the random walks every 1000 steps and then plots them in a histogram. I realise that I could literally create a new list for n=1000,2000 etc. each…
T. L
  • 103
  • 2
  • 8
1
vote
1 answer

Stopping condition if a random walk is within a range of randomly initialised values

I have a random walk on a 2D grid with randomly initialised positions. I am looking for a condition, where if the random walk is within some range of the initial positions of the other random walks, it will stop. While I found this easy to implement…
1
vote
1 answer

Code is the same as previous lines but gives an error?

I keep getting TypeError: 'int' object is not subscriptable within my evenly() function. equall() and gauss() work fine if I comment out the evenly function, and all I did was copy the code from them and used my stepe() function instead of step()…
1
vote
1 answer

How many paths of length n with the same start and end point can be found on a hexagonal grid?

Given this question, what about the special case when the start point and end point are the same? Another change in my case is that we must move at every step. How many such paths can be found and what would be the most efficient approach? I guess…
Skillzore
  • 748
  • 7
  • 21
1
vote
1 answer

How to speed up random choice generation with python?

I made a random walk generator with python and numpy. Given an adjency matrix, I want to sample random paths from each node. To do so, I currently made this class, which takes as input the neighbors_nodes of each node of the graph with their…
Robin
  • 1,531
  • 1
  • 15
  • 35