-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsimulation_python.py
More file actions
58 lines (33 loc) · 1.02 KB
/
Copy pathsimulation_python.py
File metadata and controls
58 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import random
days = 65
alive_plants = 1000
for i in range(1, days):
days = i
live_dead = np.random.binomial(1, .999, size=alive_plants)
daily_dead = sum(live_dead == 0)
"On day %d, %d plants died" % (days, daily_dead)
alive_plants = alive_plants - daily_dead
alive_plants
sim_runs = [0] * 1000
t1_start = process_time()
for j in range(1, 1000):
days = 65
alive_plants = 1000
for i in range(1, days):
days = i
#live_dead = np.random.binomial(1, .999, size=alive_plants)
live_dead = random.choices(range(0, 1), k = alive_plants)
daily_dead = sum(live_dead == 0)
alive_plants = alive_plants - daily_dead
sim_runs[j] = alive_plants
t1_end = process_time()
t1_end - t1_start
# Generate data on commute times.
size, scale = 1000, 10
plants_frame = pd.Series(sim_runs)
plants_frame.plot.hist(grid=True, bins=20, rwidth=0.9,
color='#607c8e')
plt.grid(axis='y', alpha=0.75)