Message Boards Message Boards

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

Mathematica data fit problem

Posted 11 years ago

Hi! Can anyone please help me? I just downloaded Mathematica and I haven't found out how it works yet... I am trying to find a fit for a set of data in Mathematica, but a problem that I don't understand seems to pop up.

FindFit[{{1900, 271306}, {1910, 260278}, {1920, 249699}, {1930, 
   277175}, {1940, 316004}, {1950, 350445}, {1960, 431463}, {1970, 
   539075}, {1980, 688956}, {1990, 833929}, {2000, 
   1014004}}, {LinearModelFit}, {271306  e^0.059 t}, t]

This is what I wrote, but it seems there is a problem because it says "search specification 271306 e^0.059 t without variables should be a list with 1 to 4 elements. >>"... What am I doing wrong?

thanks!!

POSTED BY: emy16t t
4 Replies

Also Try a ListPlot of your data and you will see it is more likely to need a quadratic fit,The last part of Fit becomes {1,x,x^2},x if you are looking for a quadratic fit.

Try This:

Fit[{{1900, 271306}, {1910, 260278}, {1920, 249699}, {1930, 
   277175}, {1940, 316004}, {1950, 350445}, {1960, 431463}, {1970, 
   539075}, {1980, 688956}, {1990, 833929}, {2000, 1014004}}, {1, x},x]

Notice the {1,x},x at the end indicates a Linear Fit is reqeusted. Check Documentation,List of Functions and lookup Fit Good Luck

If you are new to using the Wolfram Language for programming, take a look at the Virtual Book which will show you some of the basics about how to program with it:

http://reference.wolfram.com/language/tutorial/VirtualBookOverview.html

It's best to get a good overview of the language before trying to use it.

POSTED BY: Sean Clarke

It is important to use the correct syntax when calling a function. Built in functions and constant are capitalized. Instead of:

271306 e^0.059 t

Try writing out:

271306 E^(0.059 t)

Take a look at the documentation for FindFit. FindFit takes 4 arguments. You have provided 4 arguments in your example above, but they aren't the correct kind. You most likely are looking to run something like:

data = {{1900, 271306}, {1910, 260278}, {1920, 249699}, {1930, 
277175}, {1940, 316004}, {1950, 350445}, {1960, 431463}, {1970, 
539075}, {1980, 688956}, {1990, 833929}, {2000, 1014004}};

FindFit[data, a E^(t) + b, {a, b}, t]
POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract