I have a curve fitting problem of the form: $$ \textbf{y} = f(\textbf{x}, a,b,c,d) + \varepsilon $$ $$ f(x, a,b,c,d) = \frac{b}{e^{x\cdot a}+c}+d $$ with the constraint \begin{equation} \begin{aligned} \arg\min_{a,b,c,d} \quad & \sum_{i=1}^{n}{(f(\text{x})_i-\text{y}_i)^2}\\ \textrm{s.t.} \quad & -c-\frac{b}{d}-1 = 0\\ \quad & a = 1 \\ \end{aligned} \end{equation}
where
- $\textbf{x}, \textbf{y} \in \mathbb{R}^n$. $\textbf{x}, \textbf{y}$ are the data given by an experiment
- $a \in \mathbb{R}$
- $b \in \mathbb{R}$
- $c \in \mathbb{R}$
- $d \in \mathbb{R}$ Note: $a = 1$ because this parameter is being measured by a measurement in an experience and is, therefore fixed.
The simulated data and the following code are as follows:
import cvxpy as cp
import numpy as np
import matplotlib.pyplot as plt
n = 20
np.random.seed(1)
def sigm01(x,a,b,c,d):
return b/(np.exp(x*a)+c)+d
start = -10
end = -start
x = np.arange(start,end,0.01)
a = 1
b = -2
c = 1
d = 1
y = sigm01(x,a,b,c,d) + np.random.randn(len(x))/10
#plt.plot(x,y)
#plt.show()
I would like to use an optimization package (such as scipy
, cvxpy
or Convex.jl
).
How could I setup the problem?
d
should be part of the argmin and the phrase "a=1 in the generated data" seems confusing. $\endgroup$