-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
47 lines (38 loc) · 1.48 KB
/
script.py
File metadata and controls
47 lines (38 loc) · 1.48 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
# Final Project
import numpy as np
import matplotlib.pyplot as plt
windows_v = [
{"name": "Win 3.1", "L": 0.10, "t0": 1992.5},
{"name": "Win 95/98", "L": 0.20, "t0": 1998},
{"name": "Windows 2000", "L": 0.35, "t0": 2001},
{"name": "Win XP", "L": 0.75, "t0": 2005.5},
{"name": "Win Vista", "L": 0.15, "t0": 2009},
{"name": "Win 7", "L": 1.35, "t0": 2012.5},
{"name": "Win 8", "L": 0.13, "t0": 2014},
{"name": "Win 10", "L": 0.80, "t0": 2019},
{"name": "Win 11", "L": 0.35, "t0": 2026},
]
def logistic(L, k, t0, t):
return L / (1 + np.exp(-k * (t - t0)));
years = np.linspace(1989, 2031, 1000);
plt.figure(figsize=(14, 7));
colors = ['blue', 'green', 'magenta', 'red', 'purple', 'orange', 'brown', 'pink', 'cyan',];
for i, v in enumerate(windows_v):
rise = logistic(v["L"], 0.5, v["t0"], years);
if i < len(windows_v) - 1:
next_v = windows_v[i+1];
fall = logistic(v["L"], 0.5, next_v["t0"], years);
else:
fall = 0;
share = rise - fall;
plt.plot(years, share, label=v["name"], color=colors[i], linewidth=2);
milestones = [1995.33, 1999.5, 2003.33, 2007.33, 2010.66, 2013.33, 2016.5, 2022.5];
colors = ['blue', 'green', 'magenta', 'red', 'purple', 'orange', 'brown', 'deeppink'];
for m, c in zip(milestones, colors):
plt.axvline(m, color=c, linestyle='-.', alpha=0.2);
plt.title("Windows Versions Market Share Over Time");
plt.xlabel("Year(s)");
plt.ylabel("Market Share");
plt.grid(True);
plt.legend(loc="best");
plt.show();