Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- """
- Y = [9, 13, 17, 21, 25, 31, 40, 49]
- X = [5, 7, 10, 13, 15, 20, 25, 30]
- """
- X = [1, 2, 3, 4, 5, 7, 8, 10]
- Y = [6, 12, 18, 23, 28, 39, 44, 56]
- for i in range(8):
- X[i] *= math.sqrt(2)
- """
- res = []
- for i in range(8):
- res.append(round(L[i] / (U[i] * math.sqrt(2)), 2))
- print(res)
- """
- """
- UiLi = 0
- U2 = 0
- for i in range(8):
- UiLi += U[i] * L[i]
- U2 += U[i] ** 2
- d_avg = UiLi / (U2 * math.sqrt(2))
- print(d_avg)
- d_avg = math.sqrt(1 / 7 * (Ui2 * Li2 - UiLi ** 2) / Ui2 ** 2)
- print(d_avg)
- """
- x = 0
- y = 0
- x2 =0
- xy = 0
- for i in range(8):
- x += X[i]
- y += Y[i]
- xy += X[i] * Y[i]
- x2 += X[i] ** 2
- x /= 8
- y /= 8
- x2 /= 8
- xy /= 8
- k = round((xy - x * y) / (x2 - x ** 2), 2)
- b = round(y - k * x, 2)
- print(k, b)
- def f(x):
- return k * x + b
- #print(f(8 * math.sqrt(2)))
- #print(X)
- #for i in range(8):
- # X[i] = round(X[i], 1)
- #print(X)
- #print(Y)
- x = [4, 8, 12, 16]
- y = [0] * 4
- for i in range(4):
- y[i] = f(x[i])
- print(x)
- print(y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement