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

How can I create a random walk with elements of a dataframe in R?

Good evening, I have a dataframe with 100 rows and the column headers are ID, x-coordinate and y-coordinate: ID X Y 1 0.1 0.1 2 0.2 0.2 and so on. I would now like to simulate a random walk between these 100 points, but do not know how…
0
votes
1 answer

Error in list index when converting from R to python

I'm trying to convert my R code set.seed(2021) startn <- 10 j <- 1 maxj <- 10^5 n <- startn time <- 0 while (n[j] > 0 & j < maxj){ time[j+1] <- time[j] + rexp(1, rate=2*n[j]^2/5) n[j+1] <- n[j] + sample(c(-1,1),1) j <- j+1 …
user309575
  • 41
  • 5
0
votes
2 answers

Simulating a Random Walk with a drift (using a for loop)

I am trying to build a simulation of a random walk process with a drift using a loop, however, I am not able to get any outputs and instead I get a length error (number of items to replace is not a multiple of replacement length) which I can't fully…
0
votes
1 answer

Subscript out of bounds, iteration for a bound random walk

I am trying to write a function that generates a random walk bound by the unit sphere, resulting in the last location of the random walk given by a vector. In trying to figure out where my function is breaking, I have tried piecing it out like…
bmoscona
  • 15
  • 4
0
votes
1 answer

Trying to make a 2-D random walk function, why am I getting "unsupported operand type(s) for +: 'float' and 'NoneType'" error?

Here I made a 2-D random-walk where the "character" can only move straight up, down, left or right: import random import numpy as np import matplotlib.pyplot as plt # I define the possible moves at each step of the 2D walk dirs = np.array( [ [1,0],…
BoyAcc
  • 193
  • 7
0
votes
1 answer

Migration Matrix in a Two-Dimensional Torus-Like Space: create a migration matrix in R

I'm working on a standard problem in random walk in two dimension. In particular, I'm trying to generate a migration matrix for a toroidal model (Toroidal Transition Matrix) in R. I have previously posted the same problem here: Transition matrix for…
CafféSospeso
  • 1,101
  • 3
  • 11
  • 28
0
votes
0 answers

Random Walk to a Time Series in R

I am trying to answer the following question" The time series given below gives the price of a dozen eggs in cents, adjusted for inflation. Fit a random walk to the time series egg.ts. What is the SS1PE? library(tsdl) eggs.ts <- tsdl[[440]] I…
hoke9
  • 1
  • 1
0
votes
0 answers

Possible ways to incorporate topography in a correlated random walk in R?

I was wondering which possibilities there are for incorporating topography in a correlated random walk in R. I have a digital elevation model (DEM) of the study area. I would like for my random walk to avoid areas with a steep slope. walk <-…
neòinean
  • 39
  • 7
0
votes
0 answers

Boundary limit for correlated random walk in R

I need to create a boundary for my correlated random walk. This boundary is based on a mask of my study area (raster file). In my for loop I want to add a repeat{} loop which breaks whenever the value of the raster is 0 (and not 1). How would I go…
neòinean
  • 39
  • 7
0
votes
1 answer

Segmentation fault, while running a Monte-Carlo-random-walk simulation in c++

I am trying to simulate a random walk of 2000 particles, while the one boundary has the ability to make particles bound on that and merely perform a biased step. There are of course probabilities for binding unbinding etc... Below I have the whole…
0
votes
3 answers

Random walk Python exercise loop

I am doing python exercise and I can not finish it. I need to a create array and fill it 25 numbers, every number will be the sum of previous one and the value drawn from the set (-5, 5). import numpy as np import random def prog_list(mylist): …
Coya
  • 13
  • 3
0
votes
1 answer

How does one sample a random walk on a circle with a Gaussian step size in R or Python?

I am trying to obtain samples of a random walk on a circle that takes steps according to N(0, \sigma). To do this for a discrete random walk one calculates the cumulative sum of {+1,-1} coin tosses and then does mod the number of states on the…
hawk.q852
  • 3
  • 2
0
votes
0 answers

Extraction of data from a plot

Is it possible to extract data from a plot - for example when having the plot of a random walk, is it possible to quantify the amplitudes of fluctuations etc just because of the plot.
0
votes
0 answers

How to get the min and max of a minimum range, along with the min and max of a maximum range of the same set of numbers

I'm getting a stream of numbers from a random walk, and I'm successfully getting the min and max from that random walk using this code: const rw = require('random-walk') const num = new rw let nums = [] num.on("result", number => { …
Dshiz
  • 3,099
  • 3
  • 26
  • 53
0
votes
0 answers

Need to create a matrix with an unspecified amount of rows so that a for loop can write values to the matrix

I am modeling the drunkards walk in 2D ( a variation of a random walk which ends if the drunk man falls off a cliff). I need to know if there is any way to create the matrix "walk" without specifying the number of rows initially. I was thinking…