Questions tagged [fitting]

Questions on the use of Mathematica to construct models for approximating empirical data.

Questions on how to construct models for approximating empirical data. This involves functions that perform fitting, like FindFit, Fit, LinearModelFit, NonlinearModelFit, GeneralizedLinearModelFit etc. and objects that represent fitted models (FittedModel).

Useful links

1736 questions
47
votes
7 answers

Fitting points to tilted, off-center ellipse

I have 24 x-y points that are supposed to form an…
seismatica
  • 5,101
  • 1
  • 22
  • 33
31
votes
3 answers

What is the difference between FindFit and NonlinearModelFit

I cannot get the difference between these two fitting functions in Mathematica. I even read in MMA that the result of these two are the same.
MOON
  • 3,864
  • 23
  • 49
26
votes
6 answers

Problem with NonlinearModelFit

I'm having trouble with a non-linear fit: fit = NonlinearModelFit[data, y0 + A Sin[\[Pi] (x - xc)/w], {y0, xc, A, w}, x] where data has about 15 thousand points and looks like this: The data can be downloaded here. Mathematica gives the…
a06e
  • 11,327
  • 4
  • 48
  • 108
24
votes
3 answers

Sensitivity of NonlinearModelFit to model

I have come across a circumstance where NonlinearModelFit is very sensitive to the model used. I am aware that NonlinearModelFit is very dependent on the initial estimates and this dictated my choice of model -- I thought I had chosen a good model.…
Hugh
  • 16,387
  • 3
  • 31
  • 83
24
votes
1 answer

Difference between Fitting Algorithms

I am new to Mathematica, and I don´t quite understand, what the difference between the fitting algorithms Fit, FindFit, LinearModelFit, NonLinearModelFit are. Why is the syntax so different ({1,x,x^2} vs. a + b x + c x^2)? Which should I prefer for…
Luca Thiede
  • 439
  • 3
  • 10
22
votes
3 answers

Fitting fractional complex data with NonlinearModelfit

I've difficulites with the NonlinearModelFit function. In principle Mathematica should be able to deal with complex data. E.g. if I define the following table set = Table[{i, (3*i^2*I + 1*I)}, {i, 0, 10}] and perform NonlinearModelFit, Mathematica…
Justus
  • 221
  • 2
  • 4
21
votes
2 answers

FindFit returns Infinity::indet error when data contains {0,0}

Let's consider the following data: data = Table[{q, 2*q^2}, {q, 0, 2}]; and then, do a very simple fitting to this data: FindFit[data, a*q^b, {a, b}, q] I get the answer: Infinity::indet: Indeterminate expression 0. (-\[Infinity]) encountered.…
P. Fonseca
  • 6,665
  • 2
  • 28
  • 60
21
votes
5 answers

Using FindFit to fit $a\,b^t$: how to avoid introducing complex numbers?

I'd like to find a model $f(t)=a\,b^t$ which matches the following data data = {{0.0, 100.0}, {0.02, 81.87}, {0.04, 67.03}, {0.06, 54.88}, {0.08, 44.93}, {0.10, 36.76}}; I tried this: FindFit[data, a*b^t, {a, b}, t] But that results in an…
dharmatech
  • 919
  • 2
  • 11
  • 19
19
votes
1 answer

What are the practical differences between Fit, NonlinearModelFit, and FindFit

What are the practical differences between: FindFit,NonlinearModelFit,and Fit. Do they call different fitting algorithms and routines? How can one tell which is best to use in a certain situation. How is it best to use them once you've chosen?
user27119
  • 2,500
  • 13
  • 34
19
votes
3 answers

How to use FindFit to fit an implicit function?

Now I am trying to fit some data with a implicit model function. Firstly, I tried a toy example. Toy example with input and output data = {{1, 1}, {2, 1.4}, {3, 1.8}, {4, 2.4}, {5, 2.9}}; fitfunc[a_,b_,x_] := y /. FindRoot[a y + b Log[y] == x, {y,…
lyon
  • 191
  • 1
  • 4
18
votes
1 answer

Compact Rational Function Fitting

I have some data from a study that I am trying to fit with a rational function of arbitrary form: $y(x) = \frac{\sum_{i=n}^m A_ix^{i/q}}{\sum_{j=o}^p B_jx^{j/r}}$ where $i$, $j$, $k$, $l$, $m$, $n$, $o$, $p$, and $q$ are all integers. The goal is to…
Guillochon
  • 6,117
  • 2
  • 31
  • 57
18
votes
1 answer

Using perpendicular offsets in FindFit

I want to use perpendicular offsets in the built-in FindFit function. Are there any possible ways or do I have to code everything by myself?
15
votes
1 answer

Fittting data with combination of an unknown number of Gaussians

I have data that I want to fit with a constant plus a combination of Gaussians, with their actual number being one parameter of the fit (besides the average and the variance of every one of them). How can I carry out and test such procedure in…
psmith
  • 815
  • 2
  • 7
  • 20
14
votes
4 answers

Why does `FindFit` fail so badly in this simple case?

Consider data = {{-0.023, 0.019}, {-0.02, 0.019}, {-0.017, 0.018}, {-0.011, 0.016}, {-0.0045, 0.0097}, {-0.0022, 0.0056}, {-0.0011, 0.003}, {-0.0006, 0.0016}} Nothing extraordinary with this dataset: ListPlot@data Why does FindFit…
anderstood
  • 14,301
  • 2
  • 29
  • 80
14
votes
2 answers

Fit a function to data so that fit is always equal or less than the data

I have a set of measurement data and I try to fit there a function (a Exp[b x] + c Exp[d x] - o). I have two problems: The fit function does not converge nor after $500$ iterations. The fit function always has to be equal or less than the data…
Lutscher
  • 143
  • 5
1
2 3
27 28