Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import matplotlib.pyplot as plt
- def fraction(x):
- return x - int(x)
- v = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 3, 5, 15, 17, 51, 85, 255, 257, 771]]
- w = 0
- r = 0
- q = []
- p = 9
- Vx = []
- Vy = []
- for i in range(1, p + 1):
- m = 1 + int(math.log(i) / math.log(2))
- for j in range(1, 3):
- r = 0
- for k in range(1, m + 1):
- w = 0
- for l in range(k, m + 1):
- w = w + int(2 * fraction(i * 2 ** (-l))) * int(2 * fraction((v[j - 1][l - 1] * 2 ** (k - 1 - l))))
- r = r + (2 ** (-k + 1)) * fraction((1 / 2) * w)
- q.append(r)
- if j == 1:
- X = r
- Vx.append(X)
- if j == 2:
- Y = r
- Vy.append(Y)
- print(q)
- plt.scatter(Vx, Vy)
- plt.xlim(0, 1)
- plt.ylim(0, 1)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement