0

I need to apply curve fitting (look at the graph). However, I am struggling to find the initial parameters based on a visual (looking at the plot). So how do I now which value to pick for a, b or c. Do you have any doc that I could read?

graph

I am trying to implement this equation:

def func(t, a, b, c):   
    t0 = new_time[maximum_force_index]
    return a*np.exp(-b*(t-t0))+c

as well as curve fitting

popt, pcov = curve_fit(func, t, f)
3
  • Here is a doc that you could read: en.wikipedia.org/wiki/Exponential_decay Commented Aug 15, 2023 at 13:28
  • What does the plot look like if you use a logarithmic y axis? Commented Aug 15, 2023 at 13:30
  • This is what I'd do. First, I'd change func to not make it dependent on a global scope variable. I'd add it as a parameter. Then, I'd look at the parameters and see what they mean to the equation. c should be around 8, the y shift. a should be close to your first y value, but since this is shifted, I'd start at that then lower. b is hard, I keep varying it and plotting the result. t0 should be the x shift. c~9, a~0.8, b~0.5, t0~16. These should give a good enough guess to curve_fit. Commented Aug 15, 2023 at 17:50

1 Answer 1

5

Note that your model equation y = a * exp(-b * (t-t0)) + c is not well written because the four parameters a, b, t0 , c are not independent.

y = a * exp(-b * (t-t0)) + c = A * exp(-b*t) + c where A = a * exp(b * t0) which is a relationship between the parameters likely to cause trouble in nonlinear regression.

They are only three independant parameters. Better choose the equation model y = a *exp(-b * x) + c or equivalently y = exp(-b * (x-t0)) + c with a = exp(b * t0).

If you have some difficulties to guess initial values of the parameters in order to start an iterative nonlinear regression you can use another method which isn't iterative and doesn't requires initial values.

The general principle is explained in https://fr.scribd.com/doc/14674814/Regressions-et-equations-integrales

Un example of numerical calculus is shown below.

In order to make the example easier to copy and reproduce only 20 points where taken among your points. Moreover without your data on numerical form the points where taken by graphical scanning from the figure published in the question. This is not accurate and will probably not give good results.

The page below is the screen copy of the page from MathCad sofware.

enter image description here

You could proceed on the same manner with your full data. The values that you will get could be used as very good initial values for any usual nonlinear regression software.

Be carefull with the notations a, b, c, which are not the same above than the notations in your question.

IN ADDITION :

A better fitting is obtained with an equation model made of two exponentials.

enter image description here

Blue curve : Fitted function.

Red points : Comming from scanning the pixels (2399 points) on the graph pubished by Magdalena Rodríguez in the question.

Equivalent equation (same blue curve) :

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

;) don't like the value for b. What about exponential + linear?
@mikuszefski . If you don't like the value for coefficient b you can use the equivalent equation without coefficient b given in addition at the end of my answer
;) that's funny. Math wise I am ok with it. It's more about trying to make sense out of it from a physics point of view. Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.