(* Using linear or non-linear list square fit for USD/EUR rates *) << Statistics`NonlinearFit` a = 2.0; b= 1150.0; (* define the interpolating interval, in days *) (* read in real exchange rate data *) data = ReadList["USD.EUR.data", {Number, Number}] plotdata = ListPlot[data, PlotLabel -> "Data points", Prolog-> AbsolutePointSize [1] ] (* Do linear least square fit to a 3rd degree polynomial*) fit = Fit[data, {1, x, x^2, x^3}, x] fit2 = NonlinearFit[data, K0 + 1.2*Sin[x/40 +K2 ], {x}, {K0, K2} ] (* fit = NonlinearFit[data, 4.0*K1*x/( 1 + K1*x), {x}, {K1, Random[Real, {0, 1} ] } ] *) Print[] Print[fit] Print[] Print[fit2] plotfit = Plot[fit, {x, a, b}, PlotStyle->{Hue[0.5], Thickness[0.005]}, PlotLabel-> "Least Square", DisplayFunction -> Identity ] plotfit2 = Plot[fit2, {x, a, b}, PlotStyle->{Hue[0.8], Thickness[0.005]}, PlotLabel-> "Least Square", DisplayFunction -> Identity ] (* Show only data and the fit *) Show[plotdata, plotfit, PlotLabel -> FontForm["circles - data, blue - Least S. Fit ", {"Courier", 15}], Prolog-> AbsolutePointSize[2], DisplayFunction -> $DisplayFunction ] Show[plotdata, plotfit2, PlotLabel -> FontForm["circles - data, blue - Least S. Fit ", {"Courier", 15}], Prolog-> AbsolutePointSize[2], DisplayFunction -> $DisplayFunction ] Clear[data] Clear[fit] Clear[fit2]