Advertisement
here2share

# predict_slide.py

Sep 9th, 2023
1,677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. # predict_slide.py # failed
  2.  
  3. import cmath
  4. import math
  5. import random
  6.  
  7. waves = 200
  8. test_length = 1000
  9. data_at_zero = [random.randint(0, 256) for _ in range(waves)]
  10. amps = []
  11. while len(amps) < waves:
  12.     rndu = random.uniform(0, 1)
  13.     if rndu not in amps:
  14.         amps += [rndu]
  15. data = []
  16. for i in range(1, test_length + 1):
  17.     data += [abs(int(sum([data_at_zero[j] * math.sin(amps[j] * i) for j in range(waves)]) % 512 - 256))]
  18.  
  19. print(data, end='\n\n\n')
  20.  
  21. window_size = 10
  22. AI = {'window': [1] * window_size}
  23.  
  24. def AI_Predicts():
  25.     global AI
  26.     prediction = int(sum(AI['window']) / len(AI['window']))
  27.     return prediction
  28.  
  29. i = test_length + 1
  30. while 1:
  31.     prediction = AI_Predicts()
  32.     data = abs(int(sum([data_at_zero[j] * math.sin(amps[j] * i) for j in range(waves)]) % 512 - 256))
  33.     valid = prediction == data
  34.     oops = ''
  35.     if not valid:
  36.         oops = '!' * 20 + ' '
  37.     print(f'{oops}at:{i} sum_of_waves: {prediction} == answer: {data} is {valid}')
  38.  
  39.     # Update the window with the actual new data point
  40.     AI['window'].pop(0)
  41.     AI['window'].append(data)
  42.  
  43.     i += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement