Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to use interpolating function with parameters as a model for NonLinearModelFit (and other integrated methods for fitting)?

Similar question was already posted earlier - How do I find the best parameter to fit my data if the model is a interpolating function?. However, answer is not covering whole fitting procedure and it is based on "do it yourself" method, since the question was only about the value of best fit parameter.

Difference is that I am asking how to use (if possible) Mathemaca's methods for fitting. NonLinearModelFit finds not only best values of parameters, but also $\chi^2$, confidence regions, correlation matrix and many more things that I use. I could calculate them on my own, but I want to use some of integrated methods.

If one defines a model in the form model[x, A, B, C], which gives a real number for a set of parameter values A, B, C and a value of x, then Mathematica knows how to play with it. Instead I have a model defined as model[A, B, C], which gives, for any set of numeric values A, B and C, a pure function or a function of x on some range. Now how to explain that to Mathematica and to use NonLinearModelFit? One thing I could do is to redefine pure function model[A, B, C] to model[x, A, B, C], but that would require calculating the whole slope model[A, B, C] while taking its value at only one point x, and then repeating this procedure for every point x. This takes too long if one has big set of data points (with errors) to fit.

Is there a better idea?

share|improve this question
Perhaps you can memoize the function model[A,B,C] part and define model[x_, A_, B_, C_] = model[A,B,C][x] – ssch Jun 17 '13 at 16:07
That's exactly what I did :) Still, I miss such a feature integrated in Mathematica. – Vladimir Jun 25 '13 at 23:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.