Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. list = [100, 90, 81, 70, 72, 75, 85, 57, 90, 97, 105, 107, 105, 95, 120, 82, 72, 61, 49, 25, 53, 55]
  2. # list[7], list[14] and list[19] are the outliers in this scenario.
  3. # outliers should not exist in first 4 numbers.
  4.  
  5. # 실시간을 가정한 것이라 n 이후의 값을 내다 볼 수 없다는 전제 하에 작동.
  6.  
  7.  
  8. # error tolerance level
  9. etl = 0.2
  10.  
  11. minimum = 1 - etl
  12. maximum = 1 + etl
  13.  
  14. # predict list[n]
  15. n = 4
  16.  
  17. for i in range(0, len(list) - 4):
  18.         p1 = list[n-1]
  19.         p2 = list[n-2]
  20.         p3 = list[n-3]
  21.         p4 = list[n-4]
  22.         delta = ((p1 - p2) + (p2 - p3) + (p3 - p4)) / 3
  23.         prediction = list[n-1] + delta
  24.  
  25.         if prediction*minimum <= list[n] <= prediction*maximum:
  26.             pass
  27.         else:
  28.             list[n] = int(prediction)
  29.  
  30.         print(list)
  31.  
  32.         n += 1
  33.         i += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement