I have the following (time, position) dataset
dataset = {{0, 0}, {0.0198413, 4.35004}, {0.0396825, 11.31}, {0.0595238,
17.4}, {0.0793651, 23.49}, {0.0992064, 26.97}, {0.238095,
66.99}, {0.257937, 73.08}, {0.277778, 78.3}, {0.297619,
84.39}, {0.31746, 91.35}, {0.337302, 95.7}, {0.357143,
102.66}, {0.376984, 106.14}, {0.396825, 112.23}, {0.416667,
118.32}, {0.436508, 124.41}, {0.456349, 131.37}, {0.47619,
138.33}, {0.496032, 145.29}, {0.515873, 150.51}, {0.535714,
156.6}, {0.555556, 162.69}, {0.575397, 168.78}, {0.595238,
175.74}, {0.615079, 180.09}, {0.634921, 187.05}, {0.654762,
192.27}, {0.674603, 198.36}, {0.694444, 203.58}, {0.714286,
210.54}, {0.734127, 214.02}, {0.753968, 220.98}, {0.77381,
227.07}, {0.793651, 233.16}, {0.813492, 239.25}, {0.833333,
243.6}, {0.853175, 248.82}, {0.873016, 254.91}, {0.892857,
260.13}, {0.912698, 264.48}, {0.93254, 272.31}, {0.952381,
275.79}, {0.972222, 281.01}, {0.992063, 286.23}, {1.0119,
294.06}, {1.03175, 298.41}, {1.05159, 303.63}, {1.07143,
308.85}, {1.09127, 314.94}, {1.11111, 319.29}, {1.13095,
324.51}, {1.15079, 329.73}, {1.42857, 388.02}, {1.44841,
393.24}, {1.46825, 396.72}, {1.50794, 410.64}, {1.52778,
411.51}, {1.5873, 421.95}, {1.60714, 425.43}, {1.62698,
428.91}, {1.64683, 429.78}, {1.66667, 432.39}, {1.68651,
435.87}, {1.70635, 439.35}, {1.72619, 442.83}, {1.74603,
448.05}, {1.76587, 452.4}, {1.78571, 456.75}, {1.80556,
460.23}, {1.8254, 464.58}, {1.84524, 467.19}, {1.86508,
469.8}, {1.88492, 471.54}, {1.90476, 474.15}, {1.9246,
475.89}, {1.94444, 479.37}, {1.96429, 481.98}, {1.98413,
486.33}, {2.00397, 488.94}, {2.02381, 492.42}, {2.04365,
495.03}, {2.06349, 498.51}, {2.08333, 501.12}, {2.10317,
504.6}, {2.12302, 507.21}, {2.14286, 508.95}, {2.1627,
512.43}, {2.18254, 515.91}, {2.20238, 518.52}, {2.22222,
522.}, {2.24206, 523.74}, {2.2619, 525.48}, {2.28175,
528.09}, {2.30159, 532.44}, {2.32143, 534.18}, {2.34127,
536.79}, {2.36111, 539.4}, {2.38095, 542.01}, {2.40079,
544.62}, {2.42063, 547.23}, {2.44048, 547.23}, {2.46032,
549.84}, {2.48016, 553.32}, {2.5, 555.93}, {2.51984,
558.54}, {2.53968, 559.41}, {2.55952, 562.02}, {2.57937,
563.76}, {2.59921, 566.37}, {2.61905, 568.11}, {2.63889,
571.59}, {2.65873, 573.33}, {2.67857, 577.68}, {2.69841,
577.68}, {2.87698, 595.08}, {2.89683, 596.82}, {2.91667,
598.56}, {2.93651, 601.17}, {2.95635, 603.78}, {2.97619,
606.39}, {2.99603, 607.26}}.
To my eyes they do not look very noisy. However, if I naively fit an interpolation curve and then differentiate
f = Interpolation[dataset, InterpolationOrder -> 3]
g = Interpolation[dataset, Method -> "Spline", InterpolationOrder -> 3]
Show[ListPlot[dataset], Plot[f[t], {t, 0, 3}]]
Show[ListPlot[dataset], Plot[g[t], {t, 0, 3}]]
(*Derivative of interpolation function*)
Plot[f'[t], {t, 0, 3}]
Plot[g'[t], {t, 0, 3}]
I produce a very noisy derivative.
I also tried a brute force numerical differentiation
(*Numerical derivative of data*)
newtime = Most[time] + Differences[time]/2;
newpos = Differences[pos]/Differences[time];
derivdat = Transpose[{newtime, newpos}];
p4 = ListPlot[{dataset, derivdat}, Joined -> False,
PlotLabels -> {"data", "derivative"}]
as well as smoothing the data first and then fitting an interpolation
(*Smooth data, then interpolation*)
possmoothed = MeanFilter[pos, 6]
datsmooth = Transpose[{time, possmoothed}];
int3 = Interpolation[datsmooth, Method -> "Spline",
InterpolationOrder -> 1];
p8 = ListPlot[{dataset, datsmooth}, PlotStyle -> {Black, Red}];
p9 = Plot[{int3[x], int3'[x]}, {x, 0, 3},
PlotLabels -> {"data", "derivative"}];
p10 = Show[{p9, p8}, PlotRange -> All, ImageSize -> 400]
I am aware that I can obtain a good fit if I use a nonlinear model fit
nlm = NonlinearModelFit[dataset, a (1 - E^(-t/b)), {a, b}, t];
but I would like to have a method which works without assuming an underlying method (if possible). The reason being that in other datasets I expect the curve may have a point of inflection close to the center of the testing interval.