Skip to content

Instantly share code, notes, and snippets.

@tedunderwood
Created January 3, 2015 19:43
Show Gist options
  • Save tedunderwood/3f0f5c94a9e5818cb6c4 to your computer and use it in GitHub Desktop.
Save tedunderwood/3f0f5c94a9e5818cb6c4 to your computer and use it in GitHub Desktop.
# aggregate 100 random walks, with
# different start points:
# in each case take a walk of ten steps
# and add a 100-dimensional vector
# to an aggregator (allwalks)
# that has ten different entries,
# for the ten possible steps of each
# walk
import numpy as np
allwalks = list()
for i in range(10):
allwalks.append(np.zeros(100))
for j in range(100):
last=np.random.normal(0, .1, 100)
for i in range(10):
new=last+np.random.normal(0, .1, 100)
last=new
allwalks[i] += new
for i in range(10):
print(','.join([str(x) for x in allwalks[i]]))
@tedunderwood
Copy link
Author

This is in Python 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment