random-walk

Probability to visit nodes in a random walk on graph

自闭症网瘾萝莉.ら 提交于 2019-12-04 08:41:21
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 neighbor node and moves to it. When it reaches the goal node it stops. I am looking for an algorithm that, for each node, gives an indication about the probability that the agent visits it, while traveling from start to goal. Thank you. As is often the case with graphs, it's simply a matter of knowing an appropriate way to describe the problem. One way

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

时光怂恿深爱的人放手 提交于 2019-12-04 05:25:16
问题 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 on the lattice and let it perform a random walk. In this walk you will not place a time restriction, namely you will not declare a specific number of steps. The walk will stop when the particle falls on a trap.............................. ...Beware of

Visualizing a 2d random walk in python

风格不统一 提交于 2019-12-03 16:49:23
I'm trying to make a random walk in 2d, and plot the 2d walk. I've been able to make the walk, but the plot is not exactly what I wanted. Would it be possible to see the walk live in python ? Or just add a label to every point so that you know which point came first and which point came second etc. ? import numpy as np import matplotlib.pyplot as plt import random def randomWalkb(length): steps = [] x,y = 0,0 walkx,walky = [x],[y] for i in range(length): new = random.randint(1,4) if new == 1: x += 1 elif new == 2: y += 1 elif new ==3 : x += -1 else : y += -1 walkx.append(x) walky.append(y)

Random walk pandas

回眸只為那壹抹淺笑 提交于 2019-12-03 13:00:32
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 = 100 would like to build another date series starting at start_price at beginning date and growing by the random growth rates. pseudo code: P0 = 100 P1 = 100 * exp(Y2) P2 = P1 * exp(Y2) very easy to do in excel, but I cant think of way of doing it without iterating over a dataframe/series with pandas and I also bump my head doing that. have tried: p = Y2

Python Code: Geometric Brownian Motion - what's wrong?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 06:22:52
问题 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 like standard brownian motions with drift. My parameters like mu and sigma (expected return or drift and volatility) tend to change nothing but the slope of the noise process. That's my problem, it all looks like noise. Hope my problem is specific

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

瘦欲@ 提交于 2019-12-02 03:57:01
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 on the lattice and let it perform a random walk. In this walk you will not place a time restriction, namely you will not declare a specific number of steps. The walk will stop when the particle falls on a trap.............................. ...Beware of boundary conditions. When the particle reaches the borders of the lattice it shouldn’t be allowed to

Simulating a Random Walk

杀马特。学长 韩版系。学妹 提交于 2019-11-27 12:30:00
问题 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 exactly sure it's right: rw <- function(n){ x=numeric(n) xdir=c(TRUE, FALSE) step=c(1,-1) for (i in 2:n) if (sample(xdir,1)) { x[i]=x[i-1]+sample(step,1) } else { x[i]=x[i-1] } list(x=x) } Please Help! 回答1: This answer is just to explain why your code