I would like to use gnuplot to plot a running average or sometimes called a block average.
Let's say there are 1000 values of y, and x runs from 1 to 1000.
I tried plotting that many points, and it doesn't work well with gnuplot. Because of the density of points, it appears as if a given x value has two or more y values.
But, I can use a running average where I take a number of y values (e.g 100) and average them over a length of an x interval:
running average = (100 y values)/(length of interval)
How do I plot this running average given that I have a simple data file with two columns consisting of x and y values?
You can only do block averaging with gnuplot, not sliding-window averages. For block averaging, you have to map all x coordinates inside the block:
x_to_block(x) = factor*int(x/factor)
then plot the file with this filter applied and the "smooth uniq" post-filter:
plot 'data' using (x_to_block($1)):2 smooth uniq
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.