Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def conv(T, x):
- Ttmp = T[:] #skopiowanie zawartosci tablicy bez referencji
- for i in range(1, len(T)):
- T[i] = Ttmp[i -1] * x + Ttmp[i]
- T.append(x * Ttmp[len(Ttmp) - 1])
- return T
- def interpolate(X, Y):
- Tret = []
- for i in range(0, len(X)):
- Tret.append(0)
- for i in range(0, len(X)):
- T = [1]
- m = Y[i]
- for j in range(0, len(X)):
- if i != j:
- T = conv(T, -X[j])
- m = m / (X[i] - X[j])
- for j in range(0, len(T)):
- T[j] = T[j] * m
- Tret[j] = Tret[j] + T[j]
- return Tret
- X = [0.230000, 0.270000, 0.330000, 0.410000, 0.470000, 0.520000]
- Y = [0.050042, 0.100335, 0.171657, 0.255342, 0.309336, 0.376403]
- T = interpolate(X,Y)
- print T
Advertisement
Add Comment
Please, Sign In to add comment