# Tag Info

13

EDIT: If you just want a cleaner function, then stick with the excellent answers from @AntonAntonov and @MichaelE2. As they have shown, curve fitting can be done quite easily for your data in Mathematica, but it's my opinion that it's either the wrong tool for the job, or at least the results are more easily misinterpreted (unless you have a compelling ...

11

An alternative method for visualization and faster than ContourPlot with PlotPoints -> 1000 for nearly the same high quality in this case: Needs@"NDSolveFEM" bmesh = ToBoundaryMesh[ ImplicitRegion[ w[x, y] < 0 && 0.8 < x < 1.0 && 0.8 < y < 1.0, {x, y}], "MaxBoundaryCellMeasure" -> 0.01]; ...

9

The goal is to get a cleaner equation how can I do this? You can use (the experimental) FindFormula. Here is an example: dsFormulas = FindFormula[N@data, x, 5, All, SpecificityGoal -> 1, RandomSeeding -> 23]; dsFormulas = dsFormulas[SortBy[#Complexity &]] Select a "cleaner" formula: formula1 = Keys[Normal[dsFormulas]][[1]] (* 5325.93 + ...

8

You need a good staring estimate for NonlinearModelFit. I would first look at your data using Fourier to get the frequencies. Thus ft = Fourier[data[[All, 2]], FourierParameters -> {-1, -1}]; nn = Length@data; freq = Table[(n - 1)/(nn 128.), {n, nn}]; ListLinePlot[Transpose[{freq, Abs[ft]}], PlotRange -> {{0, 0.002}, {0, 0.2}}] The plot shows a ...

7

The choice of basis makes a difference. You don't need a Chebyshev basis (see my comment), but a power basis $\{\,(x-c)^k\,\}_{k=0}^n$ centered at a number $c$ in the domain of the data will behave better than one centered far outside it, such as the standard power basis $\{\,x^k\,\}_{k=0}^n$. That's why the OP's polynomial looks so horrible. Two ...

6

With a little help your attempt works, it's only necessary to limit omega (remember Nyquist–Shannon sampling theorem) ! Try fitFunction =NonlinearModelFit[data , {a*Sin[omega*x + phi] + cost, (2 Pi)/3000 2 > omega > 0 }, {a, omega, phi, cost}, x , Method -> NMinimize ] Show[{ Plot[ fitFunction[x ] , {x, 0, data[[-1, 1]]}], ListPlot[data]} ]

1

Regarding the nonuniformity of the orange trace in your plot : this is a consequence of "luck". The plotting functions try to minimize the number of samples actually computed. For very smooth graphs, this works very well. However, when the function oscillates rapidly, the graph will become less accurate. A way to see this is to plot $\sin(1/x)$ ...

1

As a product of visual inspection, taking data from $\approx 80$ to $120$ and using the model $$f(a,b,\sigma_1,\sigma_2,x_1,x_2,x)=a e^{-\left(\frac{x-x_1}{\sigma_1}\right)^2}+b e^{-\left(\frac{x-x_2}{\sigma_2}\right)^2}$$ data = Get["https://pastebin.com/raw/2jgDw4iQ"]; reddata = Take[data, {990, Length[data]}]; f[a_, s1_, x1_, x_] := a Exp[-((...

Only top voted, non community-wiki answers of a minimum length are eligible