|
17 | 17 |
|
18 | 18 | sp.random.seed(3) # to reproduce the data later on |
19 | 19 |
|
20 | | -x=sp.arange(1, 31*24) |
21 | | -y=sp.array(200*(sp.sin(2*sp.pi*x/ (7*24))), dtype=int) |
| 20 | +x=sp.arange(1, 31*24) |
| 21 | +y=sp.array(200*(sp.sin(2*sp.pi*x/(7*24))), dtype=int) |
22 | 22 | y+=gamma.rvs(15, loc=0, scale=100, size=len(x)) |
23 | | -y+=2*sp.exp(x/100.0) |
24 | | -y=sp.ma.array(y, mask=[y<0]) |
25 | | -print(sum(y), sum(y<0)) |
| 23 | +y+=2*sp.exp(x/100.0) |
| 24 | +y=sp.ma.array(y, mask=[y<0]) |
| 25 | +print(sum(y), sum(y<0)) |
26 | 26 |
|
27 | 27 | plt.scatter(x, y) |
28 | 28 | plt.title("Web traffic over the last month") |
29 | 29 | plt.xlabel("Time") |
30 | 30 | plt.ylabel("Hits/hour") |
31 | | -plt.xticks([w*7*24forwin [0, 1, 2, 3, 4]], ['week %i'% (w+1) forwin |
32 | | - [0, 1, 2, 3, 4]]) |
33 | | - |
| 31 | +plt.xticks([w*7*24forwinrange(5)], |
| 32 | + ['week %i'%(w+1) forwinrange(5)]) |
34 | 33 | plt.autoscale(tight=True) |
35 | 34 | plt.grid() |
36 | 35 | plt.savefig(os.path.join(CHART_DIR, "1400_01_01.png")) |
37 | 36 |
|
38 | | -# sp.savetxt(os.path.join("..", "web_traffic.tsv"), |
39 | | -# zip(x[~y.mask],y[~y.mask]), delimiter="\t", fmt="%i") |
40 | | - |
41 | | -sp.savetxt(os.path.join( |
42 | | -DATA_DIR, "web_traffic.tsv"), list(zip(x, y)), delimiter="\t", fmt="%s") |
| 37 | +sp.savetxt(os.path.join(DATA_DIR, "web_traffic.tsv"), |
| 38 | +list(zip(x, y)), delimiter="\t", fmt="%s") |
0 commit comments