Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Suppose some data with no regular pattern is given, so common patterns of functions all fail to fit it. Then how can one find the best fitting curve? I believe there will be some data for which we can not find any regular pattern. One can try with the following data (luckily, we know that this sequence has a limit):

  {{1, 0.08888888888888872},{2, 0.13842641081508972},{3, 0.17153280014540232},
   {4, 0.19586894934728782},{5, 0.21482500502852542},{6, 0.23017213935351592},
   {7, 0.24294479920054762},{8, 0.25379708095478332},{9, 0.26316771779066082},
   {10, 0.27136463872018062},{11, 0.27861184976714762},{12, 0.28507709754351612},
   {13, 0.29088903838678592},{14, 0.29614834727916052},{15, 0.30093516063430942},
   {16, 0.30531421254734282},{17, 0.30933847047870212},{18, 0.31305176609215322},
   {19, 0.3164907360488469}}

Any help or suggestion will be appreciated!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

May be something here of use: http://mathematica.stackexchange.com/a/14232/363

data=
{{1, 0.08888888888888872},{2, 0.13842641081508972},{3, 0.17153280014540232},
 {4, 0.19586894934728782},{5, 0.21482500502852542},{6, 0.23017213935351592},
 {7, 0.24294479920054762},{8, 0.25379708095478332},{9, 0.26316771779066082},
 {10, 0.27136463872018062},{11, 0.27861184976714762},{12, 0.28507709754351612},
 {13, 0.29088903838678592},{14, 0.29614834727916052},{15, 0.30093516063430942},
 {16, 0.30531421254734282},{17, 0.30933847047870212},{18, 0.31305176609215322},
 {19, 0.3164907360488469}};

nlm = NonlinearModelFit[data, {a + b Log[c x], c > 0}, {a, b, c}, x];
Print@Normal@nlm;
Print@FindFit[data, {a + b Log[c x], c > 0}, {a, b, c}, x];
Show[Plot[nlm[x], {x, 1, Length@data}, PlotRange -> All],
 ListPlot[data, PlotStyle -> Directive[Red, PointSize[0.02]]]]

enter image description here

See also, http://reference.wolfram.com/mathematica/tutorial/CurveFitting.html - particularly the section: 'Searching for general fits to data'.

share|improve this answer
    
Thanks very much! As the example in the question, I can give more data and the sequence has a limit. But in more general case waht if we can not find a common pattern of function to fit the data very well? –  Eden Harder Aug 15 '13 at 10:12
    
I've added a link to the curve fitting tutorial. There are only a few general cases to try before one may need to resort to a polynomial fit. –  Chris Degnen Aug 15 '13 at 10:19
1  
Thanks a lot! As the example in the question, I have try some possible cases. Since the sequence will converge, a polynomial fit will not help after all. –  Eden Harder Aug 15 '13 at 10:41
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.