182 Introduction to Computational Models with Python
7 N = 12; # 12 months
8 e = np.array([10.22, 10.36, 10.49, 10.60, 10.68, 10.80,
10.88, 10.94, 11.05, 11.15, 11.26, 11.40])
9 mm = np.arange(N) # month array
10 m = mm + 1
11 print "Monthly price of electricity\n"
12
13 # Array Monthly price for electric energy
14 print e
15 # differences in sequence e
16 print "\nDifferences of the given data\n"
17 de = np.diff(e)
18 print de
19 # average of increments
20 deltax = np.mean(de)
21 print "\nAverage difference: ", deltax
22 # Calculating price of electric energy
23 ce = mm * deltax + e[0]
24 print "\nCalculated prices of electricity: \n"
25 print ce
26 print "\nData for Plotting\n"
27 for j in range(N):
28 print m[j], e[j], ce[j]
With the value of the average increment ...