We fit a exponential function for
When not taking a fixed offset of
We fit a exponential function for
When not taking a fixed offset of
#!/usr/bin/env python3 | |
import numpy as np | |
from scipy.optimize import curve_fit | |
data = np.loadtxt("agx_sram_mW_mV.txt") | |
x = data[:,0] | |
y = data[:,1] | |
def model(x, fac, s): | |
return 414 + x / 1000 * 130 * fac * np.exp(x / s / 1000) | |
def evaluate(x, y, fitted): | |
dist = np.abs(fitted - y) | |
assert len(np.where(dist > 8)[0]) == 0 | |
def fit(model, x, y): | |
popt, pcov = curve_fit(model, x, y) | |
print(popt) | |
fitted = model(x, *popt) | |
evaluate(x, y, fitted) | |
return fitted | |
fit(model, x, y) |