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
2
votes
1 answer

Numpy array comparing 2 arrays element wise with increasing offset of indicies

This here is a version of the random walk problem using only numpy arrays. To find the times the position is revisited over 500 steps we have to compare a sorted array of the positions with its offset, record the time it is near 0 and then increase…
2
votes
3 answers

How to generate random directions (N, S, E, W, none) with some kind of "momentum"?

I'm trying to perform explore a grid in a random fashion. The five possible directions I can go are north, east, south, west, and stay, all of which are equally likely, at least initially. The trouble with simply choosing a random direction from the…
user541686
  • 205,094
  • 128
  • 528
  • 886
1
vote
2 answers

python- construction of lattice which traps molecules - doesn't work right

I have this problem : Create a program which constructs a lattice of one (1) dimension and 100000 sites. In this lattice put at random positions a number of trap molecules, which will have concentration c. Put 1 particle in a random position…
George
  • 5,808
  • 15
  • 83
  • 160
1
vote
2 answers

Is there a way to make the code exploring Random Walk in 1 D space more optimal? (Without nested for loops)

Trying to explore the Random Walk algorithm on Infinite Line and I'm looking for a way to make it as optimal as possible. Here is the code: import random from collections import Counter def run(initial_pos,iterations,trials): final_pos = [] …
Cebul
  • 40
  • 6
1
vote
2 answers

How to break a random walk at destination with R

I have to generate a random walk for a sequence of positions in 2D. The person doing the random walk starts at (0,0). At every move, she goes left, right, up or down. The random walk stops if she comes back to (0,0), or until she made a 1000…
1
vote
0 answers

Extracting variance ratio from Lo and MacKinlay test in R

I'm trying to perform a Lo and MacKinlay Variance-Ratio Test in R, there is a function for this in the 'vrtest' package called "Lo.Mac". This function works as intended and everything seems okay but the problem is that the function only prints the…
1
vote
0 answers

Self-Avoiding Random Walk - Compiled Program won't execute

I'm trying to run a Self Avoiding Random Walk program using IntelliJ with the code below. The program compiles successfully however, after calling it - the terminal goes to the next line with a blank (doesn't reset) and nothing is printed out. I'm…
1
vote
1 answer

Simulating a random walk in R

How do I simulate a sequence of random variables Xn with probability distribution P(Xn=1)=1/2, P(Xn=-1)=1/2 in R? (To be used to simulate a random walk).
fran
  • 43
  • 4
1
vote
0 answers

Using a 2D random walk numerical solution to solve an equation. Have the methodology but not the execution. Details in post

Essentially, I am trying to solve the lapalcian using a random walk numerical solution. My domain is a circle, and the boundary condition is some function: f(phi) = cos(2phi). Essentially, I am trying to take a point within the 2D domain of my…
1
vote
1 answer

Executing multiple self-avoiding walks, recursively

I have a 3D simple cubic lattice, which I call Grid in my code, with periodic boundary conditions of size 20x20x20 (number are arbitrary). What I want to do is plant multiple polymer chains with a degree of polymerization N (graphs with N nodes)…
bad_chemist
  • 283
  • 1
  • 7
1
vote
2 answers

struggling to create a smooth-moving snake in p5 js - tail catching up to head

I'm putting together a p5 sketch with little wiggling snakes that move randomly across the screen. Unfortunately, the tail keeps catching up to the head every time it does a sharpish turn. Here is the function I'm using to calculate the move, I've…
1
vote
2 answers

viewing 2D DNA walk with different colours

I am interested in creating a form of RandomWalk, using DNA sequence to create the walk (eg T = up, A = down etc). I have created the code, however i am wanting to know if it is possible for each of the 4 base letters to be assigned a colour instead…
1
vote
1 answer

Random walks and diffusive behaviour Python

The signature of diffusive behaviour is that the average of the square of the distance of the walker from the origin after t steps is proportional to the number of steps. Repeat the process for several walkers and step sizes (the text suggests 500…
Smirniy007
  • 13
  • 3
1
vote
1 answer

I can't turn off the axes of my plot in matplotlib

I am writing code for a random walk model, and I use plt.axes().get_xaxis().set_visible(False) to hide the axes but when I run the program the plot still shows both axes. Here is what I wrote: import matplotlib.pyplot as plt from random_walk import…
1
vote
2 answers

Random Walk Simulation in R

I'm trying to plot multiple simple Random Walks in R, but am having problems doing so. Please be aware that by simple Random Walk I mean the Sum of Random Variables that can either be {-1} or {1} with each values having the same probability, not…
user82931
  • 13
  • 3