Least square fit for a exponential function I'm having trubble findint the least square fit for a set of data points ($\mathbf x$) of the form $x(t)=T_{\mathrm A}-\left(T_{\mathrm A}-T_{\mathrm S}\right)e^{\frac{-t}{\tau}}$. I want to find the best fit for $T_{\mathrm A}$, $T_{\mathrm B}$ and $\tau$ (in a least-squares sense).
If the data had the form $Ae^{\frac{-t}{\tau}}$ it would be much easier but I don't know how to solve it for my case.
If anyone can help me I would much appreciate,
Thanks.
PS: This data comes from the cooling process of a Termistor and $\tau$ is related with the speed of the wind. 
 A: You want to fit the model $$x(t)=T_{\mathrm A}-\left(T_{\mathrm A}-T_{\mathrm S}\right)e^{\frac{-t}{\tau}}$$ which is nonlinear because of$\tau$. 
Then suppose you give $\tau$ an arbitrary value and call $y(t)=e^{\frac{-t}{\tau}}$. So the model becomes $$x(t)=T_A-(T_A-T_S)\,y(t)$$ which is linear. So, a basic linear regression will give $T_A$ and $(T_A-T_S)$ and the sum of squares $(SSQ)$ for this particular value of $\tau$.
Plot $SSQ(\tau)$ as a function of  $\tau$ and look for an area when you see the minimum. At this approximate point, you then know good guesses of $\tau,T_A-T_S$. Now, you can start the nonlinear regression.
Edit
Assuming that the data do not show large errors, select as first point the one corresponding to the lowest time $(t_1,x_1)$, as third point the one corresponding to the largest time $(t_3,x_3)$. Now, even visually, try to find a second corresponding more or less to the mean of the $t_1$ and $t_3$  that is to say $(\frac{t_1+t_3}2,x_2)$.
Now $$A=\frac {x_2-x_1}{x_3-x_2}=\frac{e^{-\frac{t_1}\tau}-e^{-\frac{t_2}\tau}}{{e^{-\frac{t_2}\tau}-e^{-\frac{t_3}\tau}}}=e^{\frac{t_3-t_1}{2 \tau }}\implies \tau= \frac{t_3-t_1}{2 \log (A)}$$ Now, go back to $$x_1=T_A-(T_A-T_S)\,e^{-\frac{t_1}\tau}$$
$$x_3=T_A-(T_A-T_S)\,e^{-\frac{t_3}\tau}$$ from which you can easily compute $T_A$ and $(T_A-T_S)$ (two linear equatiosn for two unknown variables).
So, you have more than likely sufficiently good estimates to start the nonlinear regression.
Credit must be given to Yves Daoust for his answer to this question.
