You are viewing a single comment's thread from:

RE: Random Walk Plots In Python

in #programming8 years ago

In the steps variable, any draws that are a 1 stay a 1 and anything other than a 1 turns into a -1 with the use of Numpy's where function.

What is this a 1 stay a 1 etc? You may want to clarify the description. Also the image you have used in the beginning lacks license information. Are you sure if it is free to use?


A #steemstem mentor @dexterdev

Sort:  

I have removed the first image. The other images were generated in Python.

From here:

### Multiple Random Walks

nwalks = 200
nsteps = 100

draws = np.random.randint(0, 2, size=(nwalks, nsteps)) # 0 or 1
steps = np.where(draws == 1, 1, -1)
walks = steps.cumsum(1)

I randomly generate 0s and 1s with numpy's random.randint. Any ones stay a one which represent up jumps in the random walk. Anything other than a 1 in numpy's where function (i.e 0) turns into a -1 for a down jump. The where() function is like an if-else statement.

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.082
BTC 60573.65
ETH 1550.46
USDT 1.00
SBD 0.47