1
|
4896 Views
|
3 Replies
|
4 Total Likes
View groups...
Share
GROUPS:

# How to fit two lists with some approximation?

Posted 12 years ago
 Hi everyone I have two lists. First have numerical data and date like {{20130810,14},{20130809,13}}and this is huge list (over 3400 rows).Second is Fibonacci sequence{1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89}How can I fit second list (Fibonacci) to second column in first list (to find similar value in Fibonacci periods of time)? I can have any reasonable approximation if I like. I've tried something with Fit and FindFit but I'm stuck.
3 Replies
Sort By:
Posted 12 years ago
 You might find this function useful:toSeconds[d_] := AbsoluteTime[    ToExpression /@ {StringTake[#, 4], StringTake[#, {5, 6}],       StringTake[#, {7, 8}]}] &[ToString[d]]That will convert your timestamps to seconds since 1st January 1900; toSeconds[19000101]=0, toSeconds[20130725]=3583699200Try running this code:data = Table[{t, 2 + 3 Fibonacci[t] + RandomReal[]}, {t, 6}];FindFit[data, a + b Fibonacci[c t], {a, b, c}, t]Hopefully that can get you started-M
Posted 12 years ago
 Now I change a little my idea, but steel doesn't work. Here's my code:fibonacci = {{1, 1}, {2, 1}, {3, 2}, {4, 3}, {5, 5}, {6, 8}, {7, 13}}fmatch = Fit[fibonacci, {1, x, x^2, x^3, x^4, x^5}, x]matchdata = Fit[import, fmatch, x]And then, when I want to see this matching, I see only ListPlot:Show[ListPlot[import], Plot[matchdata, {x, 20100101, 20130810}]]import is matrix of date and some values (like in first post).I want fit Fibonacci sequence to my data, but only in part of it. Can Mathematica find best matching in only part of data (but automatically choose which part)?Below I draw what I want Red dots - my dataBlue curve (or dots if it possible) - matching Fibonacci sequence by Mathematica (I drew it by hand) Second possibility of matchingMatch Fibonacci sequence to my data when Fibonacci is period of time and values are similar (with any reasonable approximation). But in this case I have totally no idea how do that, so I want do first possibility now (but maybe this is easier, I don't know).
Posted 12 years ago
 Hi, Marcin, welcome to Wolfram Community! Could you please post the code for your attempts of fitting? Then it'd be easier for us to understand what you need and where you got stuck. Thanks!