Tuesday, November 19, 2013

how to calculate a error bar

first, compute the average (i.e., the estimator) for your measurements, by evaluating the following formula:

average = (sample1 + sample2 + ... + sampleN) / N

Replace "sample1," sample2," ... "sampleN" by the measurements, and "N" by the total number of measurements in the experiment.

Second, compute the standard deviation by evaluating the following formula:

stdDev = sqrt(((sample1 - average)**2 + ... + (sampleN - average)**2)/N) or
stdDev = sqrt(((sample1 - average)**2 + ... + (sampleN - average)**2)/(N-1)) if two DOFs depend on each other.

Finally, compute the beginning and end points of the error bars, by evaluating the following formulas:

barBegin = average - stdDev

barEnd = average + stdDev

If you want to use gnuplot, following command is used.
plot "yourfile.txt" using 1:2:3 with yerrorbars !here 1, 2, 3 are steps, mean,
and stdev, respectively
 
or you can use
plot "yourfile.txt" using 1:($2-$3):($2-$3):($2+$3):($2+$3) with candlesticks!
this will generate a candlesticks.
 
  










No comments:

Post a Comment