Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.3K Views
|
4 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Getting a curve fit for an outside input/output data set

Posted 9 months ago
POSTED BY: Sammy Berger
4 Replies

Sammy,

depending on your data (!) you alternatively can try with InterpolatingPolynomial[], e.g. like so:

inputs = {16, 22, 114, 118, 120, 121, 122, 126, 128, 131, 141, 161, 177, 213, 225, 237};
outputs = {1.6, 2.2, 10.9, 11.3, 11.5, 11.6, 11.7, 12, 12.2, 12.5, 13.4, 15.2, 16.6, 19.7, 20.7, 21.8};
table = Transpose[{inputs, outputs}];

ipolpol = Simplify[Chop[InterpolatingPolynomial[table, x]]]

(*  Out:   -0.03252010729072907`+0.10366058109484573` x - 0.0001088717878462003` x^2 + 4.586421356854481`*^-7 x^3 - 8.63811125839574`*^-10 x^4  *)
POSTED BY: Henrik Schachner
Posted 9 months ago
Attachments:
POSTED BY: David Keith
Posted 9 months ago

Hey David, thanks for chiming in. However, this data is nonlinear. The first few points fit directly to y = 0.1x, but once x is over 100, we see that we've dropped slightly below that. By the time we're in the 200s, increasing from 213 to 225 gives an increase of only 1.0, rather than 1.2.

The example you gave of (* 0.438595 + 0.0911061 x *) would mean f(16) ~ 1.9, which is significantly off the observed result of 1.6.

However, whether or not this specific dataset does end up being linear, I have some others that definitely aren't. Do you know how I could get best curve fit that checks for potential logarithmic curves, polynomial curves, and/or sigmoids?

POSTED BY: Sammy Berger
Posted 9 months ago

Hi Sammy, Look up Fit in the help system. Here is a fit to a line, since a plot of the data looks linear.

data = {inputs, outputs} // Transpose;
dataPlot = ListPlot[data]
fit = Fit[data, {1, x}, x]
(* 0.438595 + 0.0911061 x *)

You can also use LinearModelFit to fit this data, which will also return the fit statistics as properties.

POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard