Hi, I can’t make sense of this custom fitting function. It appears to be fitting a curve on a much larger scale than I would like it to. The only variables that could affect the fit are initial estimates (p0) and bounds but modifying either does not yield the desired effect. Something resembling the black dashed curve below is what I’m trying to fit, albeit with minimal data. Any help would be greatly appreciated.

`from scipy.optimize import curve_fit

import matplotlib.pyplot as plt

import numpy as np

m=np.array([155.9,133.7,6.4,57.9])

t=np.array([100,150,200,250])

def exponential(x, a, b):

return abs(a*(1-2*np.exp(-b*x)))

pars, cov = curve_fit(f=exponential, xdata=t, ydata=m, p0 = [0, 0], bounds=(-np.inf, np.inf))

fig = plt.figure()

ax = fig.add_axes([0, 0, 1, 1])

ax.scatter(t, m, s=50, color=’#00b3b3’, label=‘Data’)

ax.plot(t, exponential(t, *pars), linestyle=’–’, linewidth=2, color=‘black’)`