import numpy as np
M = 4
# for M = 4, we know from the table that the relevant bits are 1 and 4
a = np.array([1, 0, 0, 1])
# initialize x somehow
x = np.array([0, 0, 0, 0]) # this doesnt work!
x = np.array([1, 1, 1, 1])
for i in range(100):
new_x = np.dot(a, x) % 2
print(new_x)
x[0] = new_x # replace the oldest element with the newest
x = np.roll(x, -1) # roll the array so the newest element is now in its proper position