SHARE
TWEET

Untitled

a guest May 19th, 2020 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. import csv
  3. import matplotlib.pyplot as plt
  4. from statsmodels.tsa.arima_model import ARIMA
  5. import pandas as pd
  6. import numpy as np
  7.  
  8.  
  9. time = np.arange(0, 150, 1)
  10. amplitude = np.sin(time)
  11. amplitude_mirror = []
  12. for x in amplitude:
  13.     amplitude_mirror.append(x+random.uniform(-0.5,0.5))
  14. plt.scatter(time, amplitude_mirror)
  15. kryterium1 = 0
  16. kryterium2 = 0
  17. kryterium3 = 0
  18. kryterium4 = 0
  19. model = ARIMA(amplitude_mirror, order=(1, 0, 0))
  20. model2 = ARIMA(amplitude_mirror, order=(0, 0, 1))
  21. model3 = ARIMA(amplitude_mirror, order=(4, 0, 2))
  22. model4 = ARIMA(amplitude_mirror, order=(4, 1, 2))
  23. results_ARIMA = model.fit(disp=-1)
  24. results_ARIMA2 = model2.fit(disp=-1)
  25. results_ARIMA3 = model3.fit(disp=-1)
  26. results_ARIMA4 = model4.fit(disp=-1)
  27. #plt.plot(results_ARIMA.fittedvalues, color='green')
  28. #plt.plot(results_ARIMA2.fittedvalues, color='blue')
  29. plt.plot(results_ARIMA3.fittedvalues, color='red')
  30. plt.plot(results_ARIMA4.fittedvalues, color='grey')
  31. for i in range(0,len(results_ARIMA.fittedvalues)-1):
  32.     kryterium1 += (results_ARIMA.fittedvalues[i]-amplitude_mirror[i])**2
  33.     kryterium2 += (results_ARIMA2.fittedvalues[i] - amplitude_mirror[i])**2
  34.     kryterium3 += (results_ARIMA3.fittedvalues[i] - amplitude_mirror[i])**2
  35.     kryterium4 += (results_ARIMA4.fittedvalues[i] - amplitude_mirror[i]) ** 2
  36. print(kryterium1)
  37. print(kryterium2)
  38. print(kryterium3)
  39. print(kryterium4)
  40. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top