init
This commit is contained in:
commit
7177a07538
5 files changed
+159
No files matched your search
@@ -0,0 +1,75 @@
|
||||
import numpy as np
|
||||
from scipy.optimize import curve_fit
|
||||
|
||||
|
||||
# Define the function to fit
|
||||
def func(x, a, b, c):
|
||||
return a * np.exp(-b * x) + c
|
||||
|
||||
|
||||
# Load the data
|
||||
data = np.array(
|
||||
[
|
||||
[0, 0],
|
||||
[20, 0],
|
||||
[40, 1],
|
||||
[60, 2],
|
||||
[80, 3],
|
||||
[100, 5],
|
||||
[120, 6],
|
||||
[140, 7],
|
||||
[160, 9],
|
||||
[180, 11],
|
||||
[200, 13],
|
||||
[220, 15],
|
||||
[240, 17],
|
||||
[260, 19],
|
||||
[280, 21],
|
||||
[300, 23],
|
||||
[320, 26],
|
||||
[340, 28],
|
||||
[360, 31],
|
||||
[380, 34],
|
||||
[400, 36],
|
||||
[420, 39],
|
||||
[440, 42],
|
||||
[460, 45],
|
||||
[480, 48],
|
||||
[500, 52],
|
||||
[520, 55],
|
||||
[540, 58],
|
||||
[560, 62],
|
||||
[580, 65],
|
||||
[600, 69],
|
||||
[620, 72],
|
||||
[640, 76],
|
||||
[660, 80],
|
||||
[680, 84],
|
||||
[700, 88],
|
||||
[720, 92],
|
||||
[740, 96],
|
||||
[760, 100],
|
||||
[780, 104],
|
||||
[800, 108],
|
||||
[820, 112],
|
||||
[840, 117],
|
||||
[860, 121],
|
||||
[880, 126],
|
||||
[900, 130],
|
||||
[920, 135],
|
||||
[940, 140],
|
||||
[960, 145],
|
||||
[980, 150],
|
||||
[1000, 154],
|
||||
]
|
||||
)
|
||||
|
||||
# Separate the data into x and y arrays
|
||||
xdata = data[:, 0]
|
||||
ydata = data[:, 1]
|
||||
|
||||
# Fit the curve to the data
|
||||
popt, pcov = curve_fit(func, xdata, ydata)
|
||||
|
||||
# Print the fitted parameters
|
||||
print(popt)
|
||||
Reference in new issue
Block a user