I have a set of data with y error bars. I can find the mean of the data without error bars using the following:
f(x)=mean_y
fit f(x) "data" via mean_y
However, I want do find a weighted mean, taking into account the error bars. Is something like this possible in gnuplot or do I have to code it?
Thanks in advance.
You can use the using
parameter to specify a column for the errors. With three using
specifiers, the third one is interpreted as standard deviation s
and is used to compute a weight 1/s**2
for the corresponding value:
f(x) = mean_y
fit f(x) "data" using 1:2:3 via mean_y
That assumes, that your data
file has three columns, x
, z
and stdev
. If you only have two columns, z
and stdev
, you must use
fit f(x) "data" using 0:1:2 via mean_y