Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # predict_slide.py # failed
- import cmath
- import math
- import random
- waves = 200
- test_length = 1000
- data_at_zero = [random.randint(0, 256) for _ in range(waves)]
- amps = []
- while len(amps) < waves:
- rndu = random.uniform(0, 1)
- if rndu not in amps:
- amps += [rndu]
- data = []
- for i in range(1, test_length + 1):
- data += [abs(int(sum([data_at_zero[j] * math.sin(amps[j] * i) for j in range(waves)]) % 512 - 256))]
- print(data, end='\n\n\n')
- window_size = 10
- AI = {'window': [1] * window_size}
- def AI_Predicts():
- global AI
- prediction = int(sum(AI['window']) / len(AI['window']))
- return prediction
- i = test_length + 1
- while 1:
- prediction = AI_Predicts()
- data = abs(int(sum([data_at_zero[j] * math.sin(amps[j] * i) for j in range(waves)]) % 512 - 256))
- valid = prediction == data
- oops = ''
- if not valid:
- oops = '!' * 20 + ' '
- print(f'{oops}at:{i} sum_of_waves: {prediction} == answer: {data} is {valid}')
- # Update the window with the actual new data point
- AI['window'].pop(0)
- AI['window'].append(data)
- i += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement