You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
232 B

4 years ago
4 years ago
  1. import matplotlib.pyplot as plt
  2. from scipy.optimize import curve_fit
  3. def linear_model(x, a, b):
  4. y= a * x + b
  5. return y
  6. x = [0, 1, 2, 3, 4, 5]
  7. y = [15, 10, 9, 6, 2, 0]
  8. popt, pcov = curve_fit(linear_model, x, y)
  9. print(popt)