I have a time series with two columns, time and data, and would like to compute an estimate of the derivative. A crude way may use only the previous value; a better way may use the previous and the following one. It may be useful to jump n records in general, not only one. Usually I just reprocess my data, but is there a general way to skip or advance records in gnuplot, using common *nix command line tools?
Asked
Active
Viewed 79 times
1
-
1You'll get much better help if you edit your question to include sample input and required output. As StackOverflow is about helping people solve programming problems, it also helps to include your attempt to solve the problem and any error messages you may have encountered. You're also welcome include your comments and observations. See http://whathaveyoutried.com. Good luck. – shellter Dec 24 '12 at 03:46
-
1You could probably manage something like this with `awk` – mgilson Dec 25 '12 at 04:08
-
Thanks for your attention! I didn't try anything yet, hoped that it would be documented somewhere. I'll try something and update the question soon. – Bruno Kim Dec 26 '12 at 14:41
-
@BrunoKim is this question still of interest? Will you provide an example? How do you want to get to the derivative with 3 points, via a least square fit? For two points, check this: https://stackoverflow.com/q/68198576/7295599 – theozh Sep 23 '22 at 09:56
-
@theozh I have stopped using Gnuplot for a while now, but your comment made me curious if I can still find a solution. The mention of Unix tools makes me believe the timeseries computation was expensive (pbb a multibody simulation), but it was feasible to rewrite the file and include an additional column with lagged/advanced data. – Bruno Kim Oct 06 '22 at 12:37
-
@BrunoKim it would be interesting to know what your data looks like. If you have noisy experimental data you might want to smooth it first. Generally, in gnuplot you could use something like `(x0=x1,x1=x2,x2=current value)` when plotting data, so you get 3 consecutive values into variables (and the same with `y0,y1,y2`). However, it is not yet clear to me how exactly you want to calculate the slope with these 3 points. Maybe you can provide a sketch to illustrate. Alternatively, you can take only every 2nd or 3rd or Nth datapoint. It depends on your exact case. Please provide more details. – theozh Oct 06 '22 at 15:02