Is it possible to filter the noise in Gnuplot and get a plot with average values of different sets? The plot can be seen below.
To smooth noisy curves you have at least two strategies: one is to use a smoothing kernel, for example Gaussian functions, which gives you local averages. The other one is to calculate total averages or interpolation functions if you know the functional form of your data. Both can be done with gnuplot.
Since you do not provide your data files I have generated the following file filled with 1000 random values obtained from the $RANDOM
bash variable:
for i in `seq 1 1 1000`; do echo $RANDOM >> data; done
This should generate random data in the range 0 - 32767, that is the average value should be 16383.5 for a sufficiently representative data sample. Let's plot it to see how the raw data looks:
plot "data" t "data", 16383.5 t "theoretical average"
The first strategy is to use a Gaussian kernel to smooth the data (smooth kdensity
):
plot "data" smooth kdensity t "data", 16383.5 t "theoretical average"
As you see, this method gives you a good smoothing in the middle but also takes into account the lack of data points at the edges.
To prevent this from happening I can increase the "locality" of the smoothing by supplying a third column with the bandwidth (equals to 10 in this case):
plot "data" u 0:1:(10) smooth kdensity t "data", 16383.5 t "theoretical average"
The averaging of fitting requires a fit
:
fit a "data" via a
plot "data" t "data", a t "calculated average"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With