Problem 1: Every month, we have to pay for the data we have stored in the cloud thus far, plus the new data that is added in that month. We will use linear regression to predict the cost for a general month, and then we will calculate the sum of the first 12 months to calculate the cost for the whole year.
Input:
source_code/6/cloud_storage.pyimport numpy as npfrom scipy.linalg import lstsqmonth = np.array([1,2,3,4,5])bill = np.array([120.0,131.2,142.1,152.9,164.3])M = month[:, np.newaxis]**[0, 1]model, _, _, _ = lstsq(M,bill)print "Intercept =", model[0]print "month_data =", model[1]
Output:
$ python cloud_storage.pyIntercept = 109.00999999999992month_data = 11.030000000000008
This means that the base cost is base_cost=109.01 euros, ...