Skip to content

Instantly share code, notes, and snippets.

@takehaya
Created December 18, 2018 07:37
Show Gist options
  • Save takehaya/c2194b18e11c90c3993adc3cd2dcfc48 to your computer and use it in GitHub Desktop.
Save takehaya/c2194b18e11c90c3993adc3cd2dcfc48 to your computer and use it in GitHub Desktop.
import numpy as np
def main():
epock_list = [
[2.8, 2.9, 3.0, 3.1, 3.2, 3.2, 3.2, 3.3, 3.4],
[30, 26, 33, 31, 33, 35, 37, 36, 33]
]
x_2_list = list(map(lambda x: round(x**2, 2), epock_list[0]))
x_y_list = list(map(lambda x, y: round(x*y, 2), epock_list[0], epock_list[1]))
print(epock_list[0], round(sum(epock_list[0]),2))
print(epock_list[1], round(sum(epock_list[1]),2))
print(x_2_list, round(sum(x_2_list),2))
print(x_y_list, round(sum(x_y_list),2))
A = np.array(
[[round(sum(x_2_list),2), round(sum(epock_list[0]),2)]
,[sum(epock_list[0]),len(epock_list[0])]]
)
B = np.array(
[round(sum(x_y_list),2), round(sum(epock_list[1]),2)]
)
inv_A = np.linalg.inv(A)
print(A)
print(B)
print(inv_A)
s_a_b = np.dot(inv_A, B)
print(s_a_b)
print(s_a_b[0]*3.25-s_a_b[1])
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment