Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. 11.20
  2.  
  3. import numpy as np
  4. import numpy.linalg as la
  5. import matplotlib.pyplot as plt
  6.  
  7. num_year = len(year)
  8. one_years = np.ones(num_year)
  9.  
  10. xy, x, y, x2 = 0,0,0,0
  11. A = np.vstack([year,one_years]).T
  12. for i in range(num_year):
  13. x += year[i]
  14. x2 += year[i]**2
  15. y += percent [i]
  16. xy = percent[i]*year[i]
  17.  
  18. c1, c0 = np.linalg.lstsq(A, percent)[0]
  19.  
  20. plt.scatter(year, percent)
  21. plt.plot(year, c1*year + c0)
  22. plt.xlabel (" x axis")
  23. plt.ylabel("y axis")
  24. plt.title("graph ")
  25.  
  26.  
  27. ____________________________
  28. 11.21
  29.  
  30. import numpy as np
  31. import numpy.linalg as la
  32. import matplotlib.pyplot as plt
  33.  
  34. A = np.array([1+0*year,year,year**2]).T
  35.  
  36. c0, c1, c2 = np.linalg.lstsq(A, percent)[0]
  37.  
  38. plt.scatter(year, percent)
  39. plt.plot(year, c2*year**2 + c1*year + c0)
  40. plt.xlabel (" x axis")
  41. plt.ylabel("y axis")
  42. plt.title("graph ")
  43.  
  44. _______________________
  45. 11.22
  46.  
  47. import numpy as np
  48. import numpy.linalg as la
  49. import matplotlib.pyplot as pt
  50.  
  51. y_log = np.log(y)
  52. coeffs = np.polyfit(x,y_log,1)
  53. c1 = coeffs[0]
  54. c0 =np.exp(coeffs[1])
  55. pt.plot(xp, coeffs[0]*np.exp(coeffs[1]*xp))
  56. pt.plot(x, y, "o")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement