Skip to content
Snippets Groups Projects
Commit 7c7a1baa authored by David Preiss's avatar David Preiss
Browse files

Update week3/random_walker.py, week3/README.MD

parent 8cca64cc
Branches
No related tags found
No related merge requests found
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
Code is [here](random_walker.py). Code is [here](random_walker.py).
![](img/random_walker.jpg) ![](random_walker.jpg)
...@@ -22,7 +22,6 @@ def build_LFSR(seed, bits_needed=1000): ...@@ -22,7 +22,6 @@ def build_LFSR(seed, bits_needed=1000):
walker_states = np.zeros((10, 1000)) walker_states = np.zeros((10, 1000))
# create our seeds by grabbing a 16 bit number from the LSB of the current time in us # create our seeds by grabbing a 16 bit number from the LSB of the current time in us
# cheating and just adding a fixed delay to get different seeds
seeds = [] seeds = []
for i in range(10): for i in range(10):
delay = .1 delay = .1
...@@ -41,7 +40,7 @@ timestep = np.array(range(1000)) ...@@ -41,7 +40,7 @@ timestep = np.array(range(1000))
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
plt.plot(walker_states.T) # transpose it so we can plot it plt.plot(walker_states.T) # transpose it so we can plot it
# for the 3 sigma lines, we will plot the sqrt of the timestep and divide the result by 1.5 to plot above and below the mean (0) # for the 3 sigma lines, we will multiply the sqrt of the timestep and divide the result by 1.5 to plot above and below the mean (0)
plt.plot(timestep, 1.5 * np.sqrt(timestep), color='black', alpha = 0.25) plt.plot(timestep, 1.5 * np.sqrt(timestep), color='black', alpha = 0.25)
plt.plot(timestep, -1.5 * np.sqrt(timestep), color='black', alpha = 0.25) plt.plot(timestep, -1.5 * np.sqrt(timestep), color='black', alpha = 0.25)
plt.show() plt.show()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment