# How do I fit a curve into non linear data?

I did an experiment in my Uni and I collected data $$(ω,υ(ω))$$ modeled by the equation:

$$v(ω)=\frac{C}{\sqrt{(ω^2-ω_0^2 )^2 +γ^2 ω^2}}$$

where $$ω_0$$ is known. Do you know how can I fit a curve to my data $$(ω,υ(ω))$$ ? and how to find the parameter $$γ$$ through this process ?

• Can you tell us if $C$ is known? – MachineLearner Apr 1 '19 at 6:10
• Let's assume that is not known and we have to extract $C$, $ω_0$ and $γ$. – Andreas Mastronikolis Apr 1 '19 at 18:25

I used mycurvefit.com for your problem. After creating an account (or maybe without if number of parameters is 2 or less) it lets you fit your function with at most 20 data points, which was enough. Here is an example

That correctly founds the parameter (g) close to 6.

Here are 20 data points that I have generated for $$C=10$$, $$\omega_0=10$$, and $$\gamma=6$$:

w       v(w)

5.4881  0.1294
7.1519  0.1538
6.0276  0.1366
5.4488  0.1290
4.2365  0.1164
6.4589  0.1429
4.3759  0.1176
8.9177  0.1746
9.6366  0.1716
3.8344  0.1132
7.9173  0.1655
5.2889  0.1271
5.6804  0.1319
9.2560  0.1744
0.7104  0.1004
0.8713  0.1006
0.2022  0.1000
8.3262  0.1706
7.7816  0.1636
8.7001  0.1737


Copy and paste them into the data sheet at the bottom.

P.S.: an analytical answer cannot be derived since the derivative equation (derivative = 0) of mean squared error with respect to parameter $$\gamma$$ is intractable, therefore gradient descent must be used with the help of computer (similar to what this site does).

EDIT:

I've forgot to add noise to $$v(\omega)$$, here is a noisy ($$\tilde{v}(\omega) = v(\omega)+\mathcal{N}(\mu=0, \sigma=0.01)$$) version with the same parameters:

w       v(w)
7.7132  0.1512
0.2075  0.1014
6.3365  0.1559
7.488   0.1483
4.9851  0.1039
2.248   0.0868
1.9806  0.106
7.6053  0.1848
1.6911  0.1136
0.8834  0.1174
6.8536  0.15
9.5339  0.1866
0.0395  0.0973
5.1219  0.1313
8.1262  0.1656
6.1253  0.1325
7.2176  0.1562
2.9188  0.1026
9.1777  0.1877
7.1458  0.1556


which gives $$g=5.7$$, meaning 20 data points are not enough for this level of noise or higher.

If you are more interested you can learn a framework like tensorflow to build the function and fit it to arbitrarily large number of data.

Here is a simple solution that you can compute yourself. It is trivial to solve your equation for $$γ$$ as a function of the other values. We get $$γ = \sqrt{(\biggr( \frac{C}{v(ω)} \biggl) ^2 - {(ω^2-ω_0^2)^2}) / {ω^2}}$$

It is almost true that you can substitute in your values and get several estimates for $$γ$$, which you can simply average to get a good estimate. I say almost true because as $$ω$$ approaches zero, both the numerator and denominator go to zero, so the calculation becomes unstable. As long as you stay away from $$ω=0$$, this should give good results. @Esmailian provided some nice data in his answer. Using his data I get the following estimates of $$γ$$.

6.012568  5.999664  5.994524  5.991173  6.009153  5.996748  6.019433
5.998072  6.001754  5.993656  6.002409  5.985938  5.996226  5.998363
6.474674  6.525602 14.140690  5.999124  6.000368  5.998427


Three of his $$ω$$'s are less than 1. These are the ones that give the estimates of $$γ$$

6.474674  6.525602 14.140690


The mean of the remaining estimates is 5.999859. As long as you have enough $$ω$$'s that are not near zero, this should provide a good estimate of $$γ$$.