I have a dataset whose mathematical model is unknown. There is my code.
ClearAll["Global`*"]
data = {{0., 0.25}, {0.05,
0.04535957501876631}, {0.1, -0.22959683050251156}, \
{0.15000000000000002, -0.5158795465693689}, {0.2, \
-0.7301957913348458}, {0.25, -0.8011017169956666}, \
{0.30000000000000004, -0.7044608640550588}, {0.35000000000000003, \
-0.4765378605500501}, {0.4, -0.196100747567105}, {0.45,
0.05366775689601985}, {0.5, 0.2206242256461488}, {0.55,
0.29732043449572876}, {0.6000000000000001,
0.3095987116186817}, {0.65,
0.29278966180408206}, {0.7000000000000001,
0.27284518841568056}, {0.75, 0.261387359850386}, {0.8,
0.2606941881651699}, {0.8500000000000001,
0.26817927575775835}, {0.9,
0.27446733372325716}, {0.9500000000000001,
0.2592721592749264}, {1., 0.1947001957678513}, {1.05,
0.06047018239905877}, {1.1, -0.1362654725629964}, \
{1.1500000000000001, -0.3517586997981886}, {1.2000000000000002, \
-0.5183389114682548}, {1.25, -0.5755346214961556}, {1.3, \
-0.5019115834325736}, {1.35, -0.3272715823202753}, \
{1.4000000000000001, -0.11688696144090496}, {1.4500000000000002,
0.06223484823497412}, {1.5, 0.17182231969774298}, {1.55,
0.21215161276646213}, {1.6,
0.2092238920099766}, {1.6500000000000001,
0.1923165533808785}, {1.7000000000000002,
0.17854999898792742}, {1.75, 0.1720188782322812}, {1.8,
0.17190219696043543}, {1.85,
0.17794131796485643}, {1.9000000000000001,
0.18708794903860115}, {1.9500000000000002,
0.18618443013013833}, {2.,
0.15163266492815844}, {2.0500000000000003,
0.062023864530717204}, {2.1, -0.08252831016642331}, {2.15, \
-0.24937887284517374}, {2.2, -0.38250999453025925}, {2.25, \
-0.42977193986190576}, {2.3000000000000003, -0.3719090193656952}, \
{2.35, -0.23403979566383987}, {2.4000000000000004, \
-0.07150507862117503}, {2.45, 0.060544004366313964}, {2.5,
0.1338153571297475}, {2.5500000000000003,
0.15377710551268767}, {2.6,
0.1458096898465104}, {2.6500000000000004,
0.1338788539262672}, {2.7, 0.12782685785681855}, {2.75,
0.12571190340963798}, {2.8000000000000003,
0.12435717478341927}, {2.85,
0.12558951152535677}, {2.9000000000000004,
0.13173895990209336}, {2.95, 0.13577668352986438}, {3.,
0.11809163818525376}, {3.0500000000000003,
0.05703848372174477}, {3.1, -0.052171141264986065}, \
{3.1500000000000004, -0.18507407808261417}, {3.2, \
-0.2944160290738003}, {3.25, -0.3343926651223669}, \
{3.3000000000000003, -0.28748988516911944}, {3.35, \
-0.17539126742962546}, {3.4000000000000004, -0.04605407250026007}, \
{3.45, 0.054154817787421754}, {3.5,
0.10421550491962703}, {3.5500000000000003,
0.11313996787827663}, {3.6,
0.10537370919096235}, {3.6500000000000004,
0.10038340729687355}, {3.7, 0.10210038914116974}, {3.75,
0.10377607675326449}, {3.8000000000000003,
0.10043392741012536}, {3.85,
0.09569030102719618}, {3.9000000000000004,
0.09633736364909878}, {3.95, 0.10046944586840713}, {4.,
0.09196986029286065}, {4.05,
0.04939817146023659}, {4.1000000000000005, -0.035500038827273483},
{4.15, -0.14435142990428168}, {4.2, -0.23653772606398482}, {4.25, \
-0.2711141722776035}, {4.3, -0.23195026722976075}, \
{4.3500000000000005, -0.13818319486254826}, {4.4, \
-0.03223287701492064}, {4.45, 0.0461023748153309}, {4.5,
0.08116311683958738}, {4.55,
0.08441822812800531}, {4.6000000000000005,
0.0793112218398028}, {4.65, 0.08158512653257002}, {4.7,
0.09042061843787946}, {4.75,
0.09526155242756693}, {4.800000000000001,
0.08975097883615274}, {4.8500000000000005,
0.07899922694726703}, {4.9, 0.07343943043119187}, {4.95,
0.07536815287115564}, {5.,
0.07162619921504758}, {5.050000000000001,
0.04116873379851412}, {5.1000000000000005, \
-0.026744747659383464}, {5.15, -0.11831249917611593}, {5.2, \
-0.1979697358294582}, {5.25, -0.22850646569942168}, \
{5.300000000000001, -0.19488626358397199}, {5.3500000000000005, \
-0.11434128511531431}, {5.4, -0.025108144357342724}, {5.45,
0.03796511041395856}, {5.5,
0.06320989895118646}, {5.550000000000001,
0.06382472357812302}, {5.6000000000000005,
0.06230664342404383}, {5.65, 0.07136540577634531}, {5.7,
0.08639258817951433}, {5.75,
0.09382786497802414}, {5.800000000000001,
0.08625209616707691}, {5.8500000000000005,
0.06999994420319763}, {5.9, 0.058440733553212644}, {5.95,
0.05727250056847864}, {6.,
0.05578254003710749}, {6.050000000000001,
0.033377263014135045}, {6.1000000000000005, \
-0.022490638702671296}, {6.15, -0.10147596664039486}, {6.2, \
-0.1718800607438274}, {6.25, -0.19937131359947818}, \
{6.300000000000001, -0.1697753918045676}, {6.3500000000000005, \
-0.09888818685910143}, {6.4, -0.02176669865153779}, {6.45,
0.03049600690836037}, {6.5,
0.04922791880104855}, {6.550000000000001,
0.04886308340261533}, {6.6000000000000005,
0.05106071357932963}, {6.65, 0.06608738435836632}, {6.7,
0.08632956423403415}, {6.75,
0.09586370917900694}, {6.800000000000001,
0.08645125158199114}, {6.8500000000000005,
0.0654172599800155}, {6.9, 0.048478784946397874}, {6.95,
0.044061035698346705}, {7.,
0.04344348586261131}, {7.050000000000001,
0.026470804650265044}, {7.1000000000000005, \
-0.020732994511128804}, {7.15, -0.09045170867633029}, {7.2, \
-0.1539554421089161}, {7.25, -0.1791359267816674}, \
{7.300000000000001, -0.15249630720578145}, {7.3500000000000005, \
-0.08874264467440107}, {7.4, -0.02050317425559245}, {7.45,
0.023992594506665153}, {7.5,
0.038338741711232055}, {7.550000000000001,
0.03786393558494788}, {7.6000000000000005,
0.04351376744916997}, {7.65, 0.0636030295959461}, {7.7,
0.08814496194819264}, {7.75,
0.09936125416148656}, {7.800000000000001,
0.08837990298510912}, {7.8500000000000005,
0.0633196836002487}, {7.9, 0.0417630670498372}, {7.95,
0.034306558906331726}, {8., 0.033833820809153196}, {8.05,
0.020583500915716844}, {8.1, -0.020307573530223846}, {8.15, \
-0.08313247231935975}, {8.200000000000001, -0.1414477941963944}, \
{8.25, -0.16486568052709186}, {8.3, -0.14042058394731663}, {8.35, \
-0.0819872328343009}, {8.4, -0.020331161370387024}, \
{8.450000000000001, 0.018511367496210886}, {8.5,
0.029858242066679915}, {8.55, 0.029693848662359766}, {8.6,
0.038370946791177404}, {8.65,
0.06265453561103906}, {8.700000000000001,
0.09068965988664124}, {8.75, 0.10324484849113105}, {8.8,
0.09095765005921527}, {8.85, 0.06257855183652253}, {8.9,
0.03716526320884847}, {8.950000000000001,
0.027034029615809366}, {9., 0.026349806140466097}, {9.05,
0.015690013868017962}, {9.1, -0.02054847679666216}, {9.15, \
-0.07820039478789328}, {9.200000000000001, -0.13258754658167485}, \
{9.25, -0.1546551796088675}, {9.3, -0.13185376644945565}, {9.35, \
-0.07742116319072777}, {9.4, -0.020689713175164805}, \
{9.450000000000001, 0.013990045870832553}, {9.5,
0.02325362230266585}, {9.55,
0.02357119989594019}, {9.600000000000001,
0.034811360556287134}, {9.65,
0.06251408316536598}, {9.700000000000001,
0.09335737679307088}, {9.75, 0.10697279056057489}, {9.8,
0.09361765371778913}, {9.850000000000001,
0.06254266362460573}, {9.9,
0.03396806149215307}, {9.950000000000001,
0.021566854697117256}, {10., 0.020521249655974707}};
lp = ListPlot[data, PlotStyle -> {PointSize[0.01]},
DisplayFunction -> Identity];
Show[lp, DisplayFunction -> $DisplayFunction, PlotRange -> Full]
By a very long manual selection of functions, I was able to establish that this curve is well described by the following function.
Plot[0.25` E^(-0.245` t) - 0.48` E^(-0.47` t) Sin[2 \[Pi] t] -
0.51` E^(-0.253` t) Sin[2 \[Pi] t]^2 - 0.126` Sin[2 \[Pi] t]^3, {t,
0, 10}]
Very similar, isn't it?
I decided to try using the FindFormula
command.
But the result that I got does not make me happy. It turns out that this curve is described by a set of not the most complex functions, and FindFormula
cannot determine this.
fit = FindFormula[data, t, 5, TargetFunctions -> {Exp, Sin}]
Out[548]= {-0.00731088, Sin[21.096^(-23. t)], Sin[18.2321^(-15 t)],
Sin[10.8084^(-7 t)], Sin[Sin[t]]}
Show[ListPlot[data], Plot[fits, {x, 0, 10}, PlotRange -> All]]
How to choose the model structure for NonlinearFitModel
?
I would be grateful for any help.
FindFormula
is not going to help here; your data is far too complicated. If your model is truly unknown (which seems a problem by itself), then the model parameters have no meaning to you, so you could use any functional form to fit it. At that point you might as well use an interpolation, if what you need is to reproduce the shape of the function faithfully. $\endgroup$ – MarcoB Jun 25 '20 at 15:08